//Please write your properties and functions here. This part will not be replaced. protected override bool onBeforeInsert(object entitySet, InsertParameters parameters) { Visit visit = (Visit)entitySet; var doctorScheduleService = DoctorScheduleEN.GetService(""); vDoctorSchedule doctorScheduleV = doctorScheduleService.GetByIDV(visit.DoctorScheduleID, new GetByIDParameters()); ((VisitBR)BusinessLogicObject).CheckInsert(visit, doctorScheduleV); visit.VisitStatusID = (int)EntityEnums.VisitStatusEnum.Scheduled; visit.DoctorReport = null; visit.ChiefComplaint = null; visit.Description = null; // updating doctor schedule number of registered patients DoctorSchedule doctorSchedule = doctorScheduleService.GetByIDT(visit.DoctorScheduleID, new GetByIDParameters()); doctorSchedule.NumberOfRegisteredPatients++; parameters.DetailEntityObjects.Add(new DetailObjectInfo() { EntityName = vDoctorSchedule.EntityName, FnName = RuleFunctionSEnum.Update, EntitySet = doctorSchedule }); return(true); }
/// <summary> /// Reschedules the visit. /// </summary> /// <param name="visit">The visit information</param> /// <param name="oldDoctorSchedule">The old doctor schedule.</param> /// <param name="newDoctorSchedule">The new doctor schedule.</param> /// <exception cref="BRException"> /// </exception> public void RescheduleVisit(vVisit visit, DoctorSchedule oldDoctorSchedule, DoctorSchedule newDoctorSchedule) { if (visit == null) { throw new BRException(BusinessErrorStrings.Visit.Visit_Deleted); } if (newDoctorSchedule == null) { throw new BRException(BusinessErrorStrings.Visit.RescheduleVisit_DoctorScheduleDeleted); } if (visit.VisitStatusID != (int)EntityEnums.VisitStatusEnum.Scheduled) { throw new BRException(BusinessErrorStrings.Visit.RescheduleVisit_ThisVisitCannotBeChange); } if (oldDoctorSchedule.DoctorScheduleID == newDoctorSchedule.DoctorScheduleID) { throw new BRException(BusinessErrorStrings.Visit.RescheduleVisit_CantDoRescheduleOnTheSameTime); } if (oldDoctorSchedule.DoctorID != newDoctorSchedule.DoctorID) { throw new BRException(BusinessErrorStrings.Visit.RescheduleVisit_ReschuleOnlyForSameDoctor); } if (newDoctorSchedule.NumberOfAllowedPatients < newDoctorSchedule.NumberOfRegisteredPatients + 1) { throw new BRException(BusinessErrorStrings.Visit.TimeSlotIsFull); } }
public ActionResult Edit([Bind(Include = "Id,Duration,Start,End,Date,DoctorId,FacilityId,ForeignDoctorServiceId")] DoctorSchedule doctorSchedule) { if (ModelState.IsValid) { var schedule = repo.GetByIdAsNonTracking(doctorSchedule.Id); scheduleManager.DeleteSlots(schedule, schedule.DoctorFacility); repo.Update(doctorSchedule); repo.Save(); scheduleManager.PushSlots(repo.GetById(doctorSchedule.Id).DoctorFacility); return(RedirectToAction("Index")); } var doctorFacilities = doctorFacilityRepo.GetAll(); ViewBag.DoctorId = new SelectList(facilityRepo.GetDoctors(doctorSchedule.FacilityId), "Id", "Name", doctorSchedule.DoctorId); ViewBag.FacilityId = new SelectList(doctorFacilityRepo.GetAllFacilities(), "Id", "Name", doctorSchedule.FacilityId); ViewBag.ForeignDoctorServiceId = doctorServiceRepo.GetAll(); return(View(doctorSchedule)); }
public ActionResult Schedule() { HospitalContext hc = new HospitalContext(); DoctorSchedule ds = hc.DoctorSchedules.Find(1); return(View(ds)); }
public void InitializeDoctorSchedule(Guid Id) { var doctorSchedule = new DoctorSchedule() { Id = Guid.NewGuid(), DoctorId = Id }; _context.DoctorScheduleRepository.Add(doctorSchedule); string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; DateTime time = DateTime.Now; foreach (var item in days) { var schedule = new Schedule() { Id = Guid.NewGuid(), Day = item, IsWorking = true, DoctorScheduleId = doctorSchedule.Id, LunchStart = new DateTime(time.Year, time.Month, time.Day, 13, 0, 0), LunchEnd = new DateTime(time.Year, time.Month, time.Day, 14, 0, 0), WorkStart = new DateTime(time.Year, time.Month, time.Day, 8, 0, 0), WorkEnd = new DateTime(time.Year, time.Month, time.Day, 18, 0, 0) }; _context.ScheduleRepository.Add(schedule); } }
/// <summary> /// Reschedules the visit. /// </summary> /// <param name="p">parameters</param> public void RescheduleVisit(VisitRescheduleVisitSP p) { IDoctorScheduleService doctorScheduleService = (IDoctorScheduleService) EntityFactory.GetEntityServiceByName(vDoctorSchedule.EntityName, ""); vVisit visit = GetByIDV(p.VisitID, new GetByIDParameters()); OwnerPatientOrOwnerDoctorSecurity.Check("reschedule an appointment", visit, vVisit.ColumnNames.PatientUserID, vVisit.ColumnNames.DoctorID); DoctorSchedule oldDoctorSchedule = doctorScheduleService.GetByIDT(visit.DoctorScheduleID, new GetByIDParameters()); DoctorSchedule newDoctorSchedule = doctorScheduleService.GetByIDT(p.NewDoctorScheduleID, new GetByIDParameters()); // checking business rules ((VisitBR)BusinessLogicObject).RescheduleVisit(visit, oldDoctorSchedule, newDoctorSchedule); // updating old schedule (it should allow +1 number of patients) if (oldDoctorSchedule.NumberOfRegisteredPatients != 0) { oldDoctorSchedule.NumberOfRegisteredPatients--; } UpdateParameters updateParameters = new UpdateParameters(); updateParameters.DetailEntityObjects.Add(new DetailObjectInfo() { EntityName = vDoctorSchedule.EntityName, EntitySet = oldDoctorSchedule, FnName = RuleFunctionSEnum.Update }); // updating new schedule (it should allow -1 number of patients) newDoctorSchedule.NumberOfRegisteredPatients++; updateParameters.DetailEntityObjects.Add(new DetailObjectInfo() { EntityName = vDoctorSchedule.EntityName, EntitySet = newDoctorSchedule, FnName = RuleFunctionSEnum.Update }); // Adding notification for user var notification = CreateScheduleNotification(visit); notification.NotificationTemplateID = (int)EntityEnums.NotificationTemplateEnum.VisitRescheduled; TemplateParams tmpP = new TemplateParams(); tmpP.AddParameter("FromDate", DateTimeEpoch.ConvertUnixEpochToLocalTime(oldDoctorSchedule.SlotUnixEpoch, visit.PatientWorldTimeZoneID).ToString()); tmpP.AddParameter("ToDate", DateTimeEpoch.ConvertUnixEpochToLocalTime(newDoctorSchedule.SlotUnixEpoch, visit.PatientWorldTimeZoneID).ToString()); notification.ParametersValues = tmpP.SerializeToString(); updateParameters.DetailEntityObjects.Add(new DetailObjectInfo() { EntityName = vNotification.EntityName, EntitySet = notification, FnName = RuleFunctionSEnum.Insert } ); // updating visit changes visit.DoctorScheduleID = p.NewDoctorScheduleID; Update(visit, updateParameters); }
public DoctorSchedule RestoreSchedule(DoctorSchedule schedule) { schedule.IsFullfilled = false; _scheduleRepository.Update(schedule); _scheduleRepository.Save(); return(schedule); }
public ActionResult Schedule() { HospitalContext hc = new HospitalContext(); int docId = Int32.Parse(Session["DoctorId"].ToString()); DoctorSchedule ds = hc.DoctorSchedules.Find(docId); return(View(ds)); }
private DoctorSchedule CreateVisitSchedule(DoctorSchedule schedule, Visit visit, TimeSpan visitStart, TimeSpan visitEnd) { var visitSchedule = _scheduleRepository.Clone(schedule); visitSchedule.Start = visitStart; visitSchedule.End = visitEnd; visitSchedule.IsFullfilled = true; visit.DoctorSchedule = visitSchedule; return(visitSchedule); }
public static DoctorSchedule CreateNewDoctorSchedule() { DoctorSchedule doctorSchedule = new DoctorSchedule(); doctorSchedule.DoctorID = TestEnums.User.constDoctorID; doctorSchedule.SlotUnixEpoch = DateTimeEpoch.GetUtcNowEpoch() + 3000; doctorSchedule.NumberOfAllowedPatients = 3; doctorSchedule.NumberOfRegisteredPatients = 0; doctorSchedule.IsDisabled = false; doctorSchedule.IsWalkingQueue = false; return(doctorSchedule); }
public ActionResult Save([FromBody] DoctorSchedule doctorSchedule) { var result = _service.Save(doctorSchedule); if (result.Status == Domain.DataContext.Enums.EResultStatus.Success) { return(Ok(result)); } else { return(BadRequest(result)); } }
public bool DeleteSlots(DoctorSchedule schedule, DoctorFacility doctorFacility) { if (doctorFacility.IsMapped) { var mapping = doctorFacility.DoctorMapping; var address = mapping.ForeignAddress; return(_client.DeleteSlots(address.ForeignFacilityId, address.ForeignDoctorId, address.Id, schedule.Date)); } else { return(true); } }
public ActionResult Create(Doctor collection, HttpPostedFileBase ImageFile) { try { //TODO: Add insert logic here string filename = Path.GetFileNameWithoutExtension(ImageFile.FileName); string extension = Path.GetExtension(ImageFile.FileName); filename += DateTime.Now.ToString("yymmssfff") + extension; collection.ImagePath = "~/Images/Doctors/" + filename; filename = Path.Combine(Server.MapPath("~/Images/Doctors/"), filename); ImageFile.SaveAs(filename); int DeptId = int.Parse(collection.Departments); collection.Departments = _context.Departments.FirstOrDefault(x => x.Id == DeptId).Name; if (int.Parse(collection.SurgeryOrMedicine) == 1) { collection.SurgeryOrMedicine = "Surgery"; } else { collection.SurgeryOrMedicine = "Medicine"; } collection.Updated = DateTime.Now; collection.UpdatedBy = User.Identity.Name; DateTime tt = DateTime.Parse("11/11/2000"); collection.RetireDate = tt; _context.Doctors.Add(collection); _context.SaveChanges(); // Now //Here I am inserting in Docotors schedule Table // At first Schedule will Not added // DoctorSchedule Schedule = new DoctorSchedule(); int DoctorId = _context.Doctors.Where(x => x.DoctorName == collection.DoctorName).FirstOrDefault(y => y.JoinningDate == collection.JoinningDate).Id; Schedule.DoctorId = DoctorId; Schedule.DoctorName = collection.DoctorName; Schedule.Schedule = "Not yet Added"; Schedule.Updated = DateTime.Today; Schedule.UpdatedBy = User.Identity.Name; _context.DoctorsSchedule.Add(Schedule); _context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Schedule/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DoctorSchedule doctorSchedule = repo.GetById(id.Value); if (doctorSchedule == null) { return(HttpNotFound()); } return(View(doctorSchedule)); }
private DoctorSchedule DivideSchedule(DoctorSchedule schedule, TimeSpan visitStart, TimeSpan visitEnd) { var remainingSchedule = _scheduleRepository.Clone(schedule); schedule.End = visitStart; remainingSchedule.Start = visitEnd; TimeSpan leftover = remainingSchedule.End - remainingSchedule.Start; if (leftover.TotalMinutes >= remainingSchedule.Duration) { return(remainingSchedule); } return(null); }
public DoctorSchedule FindDoctorSchedule(DoctorFacility doctorFacility, DateTime start, DateTime end, string foreignDoctorServiceId) { var doctorSchedules = _scheduleRepository.GetByDateAndDoctorFacility(start, doctorFacility.DoctorId, doctorFacility.FacilityId); DoctorSchedule schedule = doctorSchedules.FirstOrDefault(ds => ds.Start <= start.TimeOfDay && end.TimeOfDay <= ds.End && ds.ForeignDoctorServiceId == foreignDoctorServiceId ); if (schedule == null) { schedule = doctorSchedules.FirstOrDefault(ds => ds.Start <= start.TimeOfDay && end.TimeOfDay <= ds.End); } return(schedule); }
public ActionResult Edit(int id, DoctorSchedule collection) { try { // TODO: Add update logic here DoctorSchedule Schedule = _context.DoctorsSchedule.Find(id); Schedule.Schedule = collection.Schedule; Schedule.Updated = DateTime.Today; Schedule.UpdatedBy = User.Identity.Name; _context.Entry(Schedule).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
// save public async Task SaveSchedule(ScheduleViewModel model) { var resultchecked = await CheckScheduleExist(model.DoctorId, model.Date); if (resultchecked == null) { var @doctorSchedule = new DoctorSchedule().Create(model.DoctorId, model.Date); var result = await _unitOfWork.DoctorScheduleRepository.CreateAndSave(@doctorSchedule); var @doctorSchedulenew = new Appoiment().Create(model.Date, model.FromTime, model.ToTime, false, model.DoctorId, model.PatientId, model.Charges, result.Id); await _unitOfWork.AppoimentRepository.CreateAndSave(@doctorSchedulenew); } else { var @doctorSchedule = new Appoiment().Create(model.Date, model.FromTime, model.ToTime, false, model.DoctorId, model.PatientId, model.Charges, resultchecked.Id); await _unitOfWork.AppoimentRepository.CreateAndSave(@doctorSchedule); } }
public ActionResult Schedule(FormCollection fc) { HospitalContext hc = new HospitalContext(); DoctorSchedule ds = null; int docId = 0; try { docId = Int32.Parse(Session["DoctorId"].ToString()); ds = hc.DoctorSchedules.First(s => s.DoctorId == docId); }catch (Exception ex) { } //int doctorId = string b = fc["DoctorName"].ToString(); string c = fc["TotalSlots"]; string d = fc["DaysOfTheWeek"].ToString(); string e = fc["Time"].ToString(); if (ds == null) { DoctorSchedule s = new DoctorSchedule { DoctorId = docId, DoctorName = b, TotalSlots = Int32.Parse(c), DaysOfTheWeek = d, Time = e }; hc.DoctorSchedules.Add(s); hc.SaveChanges(); return(View(s)); } else { ds.DoctorName = b; ds.TotalSlots = Int32.Parse(c); ds.DaysOfTheWeek = d; ds.Time = e; hc.SaveChanges(); } return(View(ds)); }
public ActionResult Schedule(FormCollection fc) { HospitalContext hc = new HospitalContext(); DoctorSchedule ds = null; try { ds = hc.DoctorSchedules.First(s => s.DoctorId == 1); }catch (Exception ex) { } //int doctorId = string b = fc["DoctorName"].ToString(); string c = fc["TotalSlots"]; string d = fc["DaysOfTheWeek"].ToString(); string e = fc["Time"].ToString(); if (ds == null) { /* * DoctorSchedule s = new DoctorSchedule * { * //DoctorId = * DoctorName = b, * TotalSlots = Int32.Parse(c), * DaysOfTheWeek = d, * Time = e * }; * hc.DoctorSchedules.Add(s); */ } else { ds.DoctorName = b; ds.TotalSlots = Int32.Parse(c); ds.DaysOfTheWeek = d; ds.Time = e; hc.SaveChanges(); } return(View(ds)); }
public ApiResult GetDoctorSchedule(string ID) { var result = new ApiResult() { Status = 0, Msg = "暂无数据" }; doctSchduleService = new DoctorSchduleService(CurrentOperatorUserID); DoctorSchedule data = doctSchduleService.GetDoctorSchedule(ID); if (data != null) { ObjectsMapper <DoctorSchedule, DoctorScheduleSingleDto> mapper = ObjectMapperManager.DefaultInstance.GetMapper <DoctorSchedule, DoctorScheduleSingleDto>(); DoctorScheduleSingleDto model = mapper.Map(data); result.Status = 0; result.Msg = "成功"; result.Data = data; } return(result); }
public Response <List <DoctorScheduleDTO> > Post(List <DoctorScheduleDTO> dsDTOS) { try { using (VDEntities entities = new VDEntities()) { foreach (var DoctorSchedueDTO in dsDTOS) { DoctorSchedule doctorSchduleDB = Mapper.Map <DoctorSchedule>(DoctorSchedueDTO); entities.DoctorSchedules.Add(doctorSchduleDB); entities.SaveChanges(); DoctorSchedueDTO.ID = doctorSchduleDB.ID; } return(new Response <List <DoctorScheduleDTO> >(true, null, dsDTOS)); } } catch (Exception e) { return(new Response <List <DoctorScheduleDTO> >(false, GetMessageFromExceptionObject(e), null)); } }
// GET: Schedule/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DoctorSchedule doctorSchedule = repo.GetById(id.Value); if (doctorSchedule == null) { return(HttpNotFound()); } var doctorFacilities = doctorFacilityRepo.GetAll(); ViewBag.DoctorId = new SelectList(facilityRepo.GetDoctors(doctorSchedule.FacilityId), "Id", "Name", doctorSchedule.DoctorId); ViewBag.FacilityId = new SelectList(doctorFacilityRepo.GetAllFacilities(), "Id", "Name", doctorSchedule.FacilityId); ViewBag.ForeignDoctorServiceId = doctorServiceRepo.GetAll(); return(View(doctorSchedule)); }
public ActionResult Create([Bind(Include = "Id,Duration,Start,End,Date,DoctorId,FacilityId,ForeignDoctorServiceId")] DoctorSchedule doctorSchedule) { if (ModelState.IsValid) { repo.Insert(doctorSchedule); repo.Save(); var doctorFacility = doctorFacilityRepo.GetByIds(doctorSchedule.DoctorId, doctorSchedule.FacilityId); scheduleManager.PushSlots(doctorFacility); return(RedirectToAction("Index")); } var doctorFacilities = doctorFacilityRepo.GetAll(); ViewBag.DoctorId = new SelectList(doctorFacilityRepo.GetAllDoctors(), "Id", "Name", doctorSchedule.DoctorId); ViewBag.FacilityId = new SelectList(doctorFacilityRepo.GetAllFacilities(), "Id", "Name", doctorSchedule.FacilityId); ViewBag.ForeignDoctorServiceId = doctorServiceRepo.GetAll(); return(View(doctorSchedule)); }
public ActionResult Delete(int id, Doctor collection) { try { var model = _context.Doctors.Find(id); model.RetireDate = DateTime.Today; _context.Entry(model).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); DoctorSchedule schedule = _context.DoctorsSchedule.FirstOrDefault(x => x.DoctorId == model.Id); _context.DoctorsSchedule.Remove(schedule); _context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ResponseModel Save(DoctorSchedule entity) { if (entity.Valid) { _uow.DoctorScheduleRepository.Add(entity); return(new ResponseModel { Status = Domain.DataContext.Enums.EResultStatus.Success, Data = entity, Message = "Horário definido com sucesso", Location = $"/api/doctorSchedule/{entity.Id}" }); } else { return(new ResponseModel { Status = Domain.DataContext.Enums.EResultStatus.Failure, Message = "Falha ao tentar definir horário" }); } }
public JsonResult SaveSchedule(int DoctorID, int EventID) { bool status = false; if (ModelState.IsValid) { using (ERP1DataContext dc = new ERP1DataContext()) { DoctorSchedule ds = new DoctorSchedule(); ds.DoctorID = DoctorID; ds.EventID = EventID; dc.DoctorSchedules.InsertOnSubmit(ds); dc.SubmitChanges(); status = true; } } else { status = false; } return(new JsonResult { Data = new { status = status } }); }
/// <summary> /// 保存排班列表 /// </summary> /// <param name="modelList"></param> public bool AddDoctorSchduleList(List <DoctorScheduleDto> request, string userId) { DateTime maxdt = request.Max(t => t.OPDate); DateTime mindt = request.Min(t => t.OPDate); request = request.OrderBy(t => t.OPDate).ThenBy(t => t.StartTime).ToList(); var hostimes = GetHosWorktime(); using (var db = new DBEntities()) { var exist = db.DoctorSchedules.Where(t => t.DoctorID == userId && t.OPDate.CompareTo(maxdt) <= 0 && t.OPDate.CompareTo(mindt) >= 0) .OrderBy(t => t.OPDate).ThenBy(t => t.StartTime).ToList(); int i = 0, j = 0; foreach (var item in exist) { item.IsDeleted = true; } for (; i < request.Count; i++) { //未选中的不处理 if (!request[i].Checked) { continue; } //不符合医院时间的,排除掉 if (!hostimes.Where(t => t.StartTime == request[i].StartTime && t.EndTime == request[i].StartTime).Any()) { request[i].Checked = false; continue; } for (; j < exist.Count; j++) { if (request[i].StartTime == exist[j].StartTime) { //数据库的设置未 未删除 exist[j].IsDeleted = false; //请求的标记未 不处理 request[j].Checked = false; } else if (request[i].StartTime.CompareTo(exist[i].StartTime) < 0) { break; } else { continue; } } } foreach (var item in request) { if (item.Checked) { DoctorSchedule ds = new DoctorSchedule() { StartTime = item.StartTime, EndTime = item.EndTime, Number = item.Number, ScheduleID = Guid.NewGuid().ToString("N"), OPDate = item.OPDate, DoctorID = userId }; db.DoctorSchedules.Add(ds); } } return(db.SaveChanges() > 0); } }
public void Update(DoctorSchedule entity) { _context.DoctorSchedules.Update(entity); _context.SaveChanges(); }
public void Add(DoctorSchedule entity) { _context.DoctorSchedules.Add(entity); _context.SaveChanges(); }