public async Task <ActionResult> _hospitalList(int doctorID, int hospitalID = 0, DateTime?AppointmentDate = null) { AppointmentDate = MyExtension.getLocalTime(DateTime.UtcNow); IEnumerable <HospitalSchedules> hospitalList = await HospitalApiRequestHelper.scheduledHospitalList(doctorID, hospitalID, AppointmentDate); return(PartialView("_hospitalList", hospitalList)); }
public HttpResponseMessage schedulebydoctorid(HttpRequestMessage request, int docid = 0, int hospitalid = 0, DateTime?appDate = null, string Type = null) { List <tbScheduleData> result = null; if (Type == null) { var today = MyExtension.getLocalTime(DateTime.UtcNow).Date; var nextsevenday = today.AddDays(7); result = scheduleRepo.GetWithoutTracking().Where(a => a.DoctorID == docid && a.HospitalID == hospitalid && a.IsDeleted != true && a.AppointmentDatetime >= today && a.AppointmentDatetime <= nextsevenday).ToList(); } else if (Type == "next") { DateTime nextDate = appDate.Value.AddDays(7); DateTime nextSevenDate = nextDate.AddDays(7); nextDate = nextDate.Date; nextSevenDate = nextSevenDate.Date; result = scheduleRepo.GetWithoutTracking().Where(a => a.DoctorID == docid && a.HospitalID == hospitalid && a.IsDeleted != true && a.AppointmentDatetime >= nextDate && a.AppointmentDatetime <= nextSevenDate).ToList(); } else if (Type == "prev") { DateTime prevDate = appDate.Value.Date; DateTime prevSevenDate = prevDate.AddDays(-7); prevSevenDate = prevSevenDate.Date; result = scheduleRepo.GetWithoutTracking().Where(a => a.DoctorID == docid && a.HospitalID == hospitalid && a.IsDeleted != true && a.AppointmentDatetime >= prevSevenDate && a.AppointmentDatetime <= prevDate).ToList(); } return(request.CreateResponse <List <tbScheduleData> >(HttpStatusCode.OK, result)); }
public ActionResult LogOut() { FormsAuthentication.SignOut(); RemoveCookie("accCookie"); Response.Cookies["accCookie"].Expires = MyExtension.getLocalTime(DateTime.UtcNow).AddYears(-30); Session.Clear(); return(RedirectToAction("Login", "Account")); }
public void DeleteCookie() { if (Request.Cookies["mc"] != null) { HttpCookie myCookie = new HttpCookie("mc"); myCookie.Expires = MyExtension.getLocalTime(DateTime.UtcNow).AddDays(-1); Response.Cookies.Add(myCookie); } }
public void SetCookie(string CookieName, int AccountId, string UserName, string Role) { HttpCookie myCookie = HttpContext.Request.Cookies[CookieName] ?? new HttpCookie(CookieName); myCookie.Values["AccountID"] = AccountId.ToString(); myCookie.Values["UserName"] = UserName; myCookie.Values["Role"] = Role; myCookie.Expires = MyExtension.getLocalTime(DateTime.UtcNow).AddDays(30); HttpContext.Response.Cookies.Add(myCookie); }
public HttpResponseMessage UpSertDOctor(HttpRequestMessage request, tbDoctor doc) { tbDoctor UpdatedEntity = new tbDoctor(); IPhoto iPhoto = new AzurePhotoUpload(); if (doc.ID > 0) { tbSpecialty specialty = specialityRepo.GetWithoutTracking().Where(s => s.ID == doc.SpecialityID).FirstOrDefault(); if (specialty != null) { doc.SpecialityID = doc.SpecialityID; doc.Specialty = specialty.Specialty; } tbDoctor doctor = doctorRepo.GetWithoutTracking().Where(d => d.ID == doc.ID).FirstOrDefault(); if (doc.Image == null) { doc.Photo = doctor.Photo; } else { doc.Photo = iPhoto.uploadPhoto(doc.Image); doc.Image = null; } UpdatedEntity = doctorRepo.UpdatewithObj(doc); } else { var result = (from t in dbContext.tbDoctors where t.Phone == doc.Phone select t).Any(); if (result == false) { tbSpecialty specialty = specialityRepo.Get().Where(s => s.ID == doc.SpecialityID).FirstOrDefault(); if (specialty != null) { doc.SpecialityID = doc.SpecialityID; doc.Specialty = specialty.Specialty; } doc.IsDeleted = false; doc.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); if (doc.Image != null) { doc.Photo = iPhoto.uploadPhoto(doc.Image); doc.Image = null; } UpdatedEntity = doctorRepo.AddWithGetObj(doc); } else { UpdatedEntity.SystemStatus = "E002"; // } } return(request.CreateResponse <tbDoctor>(HttpStatusCode.OK, UpdatedEntity)); }
public bool RemoveCookie(String CookieName) { if (HttpContext.Request.Cookies[CookieName] != null) { HttpCookie myCookie = HttpContext.Request.Cookies[CookieName]; myCookie.Expires = MyExtension.getLocalTime(DateTime.UtcNow).AddDays(-1); HttpContext.Response.Cookies.Add(myCookie); return(true); } return(false); }
public HttpResponseMessage bookinglist(HttpRequestMessage request, string name = null, string status = null, int pagesize = 10, int page = 1, DateTime?datetime = null, DateTime?time = null, int hospitalid = 2, int doctorid = 0) { DateTime?newdate = null; Expression <Func <tbAppointment, bool> > namefilter, statusfilter, hospitalidfilter, doctoridfilter = null; if (name != null) { namefilter = l => l.PatientName.Contains(name); } else { namefilter = l => l.IsDeleted != true; } if (status != null) { statusfilter = l => l.Status == status; } else { statusfilter = l => l.IsDeleted != true; } if (hospitalid > 0) { hospitalidfilter = l => l.HospitalId == hospitalid; } else { hospitalidfilter = l => l.IsDeleted != true; } if (doctorid > 0) { doctoridfilter = l => l.DoctorId == doctorid; } else { doctoridfilter = l => l.IsDeleted != true; } IQueryable <tbAppointment> result = null; if (time != null) { result = appointmentRepo.GetWithoutTracking().Where(a => a.IsDeleted != true && a.Status != "CHECKOUT" && a.Status != "CANCEL" /*&& a.AppointmentDateTime.Value.Day == time.Value.Day*/ && a.AppointmentDateTime == time).Where(hospitalidfilter).Where(doctoridfilter); } else { newdate = MyExtension.getLocalTime(DateTime.UtcNow).Date; result = appointmentRepo.GetWithoutTracking().Where(a => a.IsDeleted != true && a.AppointmentDateTime >= newdate && a.Status != "CHECKOUT" && a.Status != "CANCEL").Where(namefilter).Where(statusfilter).Where(hospitalidfilter); } PagedListServer <tbAppointment> model = new PagedListServer <tbAppointment>(result.OrderBy(a => a.IsEmergency).OrderBy(a => a.Accesstime).OrderBy(a => a.Position), pagesize, page); dbContext.Dispose(); return(request.CreateResponse <PagedListServer <tbAppointment> >(HttpStatusCode.OK, model)); }
public void SetCookie(int ID, string Name, string Username, string Role, int HospitalID, string HospitalName) { HttpCookie myCookie = HttpContext.Request.Cookies["mc"] ?? new HttpCookie("mc"); myCookie.Values["ID"] = ID.ToString(); myCookie.Values["Name"] = HttpUtility.UrlEncode(Name.ToString()); myCookie.Values["Username"] = HttpUtility.UrlEncode(Username.ToString()); // myCookie.Values["ServiceName"] = ServiceName.ToString(); myCookie.Values["Role"] = Role.ToString(); myCookie.Values["HospitalID"] = HospitalID.ToString(); myCookie.Values["HospitalName"] = Server.UrlEncode(HospitalName.ToString()); myCookie.Expires = MyExtension.getLocalTime(DateTime.UtcNow).AddDays(1); HttpContext.Response.Cookies.Add(myCookie); }
public HttpResponseMessage scheduleListbyDoctorID(HttpRequestMessage request, int doctorid = 0, string docname = null, int hospitalid = 0, DateTime?date = null) { if (date != null) { date = date.Value.Date; } else { date = MyExtension.getLocalTime(DateTime.UtcNow).Date; } var result = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doctorid && a.HospitalID == hospitalid && a.AppointmentDatetime >= date).ToList(); return(request.CreateResponse <List <tbScheduleData> >(HttpStatusCode.OK, result)); }
public HttpResponseMessage Upsert(HttpRequestMessage request, tbSchedule schedule) { tbSchedule UpdatedEntity = null; if (schedule.ID > 0) { UpdatedEntity = scheduleRepo.UpdatewithObj(schedule); } else { schedule.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); schedule.IsDeleted = false; UpdatedEntity = scheduleRepo.AddWithGetObj(schedule); } return(request.CreateResponse <tbSchedule>(HttpStatusCode.OK, UpdatedEntity)); }
public async Task <ActionResult> _scheduleListbyDoctorID(int doctorid = 0, string docname = null, DateTime?date = null) { int hospitalid = Helper.CookieHelper.getstaffHospitalID(); List <tbScheduleData> result = await BookingApiRequestHelper.scheduleListbyDoctorID(doctorid, docname, hospitalid, date); ViewBag.docid = doctorid; ViewBag.docname = docname; if (date != null) { ViewBag.Date = date.Value.Date; } else { ViewBag.Date = MyExtension.getLocalTime(DateTime.UtcNow); } return(PartialView("_scheduleListbyDoctorID", result)); }
public async Task <ActionResult> _list(int id = 0, string docname = null, DateTime?fromdate = null, DateTime?todate = null, int pagesize = 10, int page = 1) { int hospitalid = CareMeClient.Helper.CookieHelper.getstaffHospitalID(); if (fromdate != null && todate != null) { ViewBag.appDate = MyExtension.getLocalTime(DateTime.UtcNow); PagedListClient <ScheduleDoctorViewModel> result = await ScheduleApiRequestHelper.list(id, docname, fromdate, todate, pagesize, page, hospitalid); return(PartialView("_searchList", result)); } else { ViewBag.appDate = MyExtension.getLocalTime(DateTime.UtcNow); PagedListClient <ScheduleDoctorViewModel> result = await ScheduleApiRequestHelper.list(id, docname, fromdate, todate, pagesize, page, hospitalid); return(PartialView("_DoctorScheduleList", result)); } }
public HttpResponseMessage scheduledHospitalList(HttpRequestMessage request, int doctorID, int hospitalID = 0, DateTime?AppointmentDate = null) { Expression <Func <tbHospital, bool> > hospitalfilter; Expression <Func <tbScheduleData, bool> > hospitalSDfilter; Expression <Func <tbScheduleData, bool> > appointmentDateFilter; if (hospitalID > 0) { hospitalfilter = h => h.ID == hospitalID; hospitalSDfilter = h => h.HospitalID == hospitalID; } else { hospitalfilter = h => h.IsDeleted != true; hospitalSDfilter = h => h.IsDeleted != true; } if (AppointmentDate != null) { DateTime stdate = AppointmentDate.Value.Date; DateTime eddate = AppointmentDate.Value.Date.AddDays(1); appointmentDateFilter = a => a.AppointmentDatetime >= stdate && a.AppointmentDatetime <= eddate; } else { appointmentDateFilter = a => a.IsDeleted != true; } var now = MyExtension.getLocalTime(DateTime.UtcNow); List <HospitalSchedules> result = (from h in dbContext.tbHospitals.Where(a => a.IsDeleted != true).Where(hospitalfilter) join hsd in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doctorID && a.AppointmentDatetime >= now) .Where(hospitalSDfilter) on h.ID equals hsd.HospitalID //.Where(appointmentDateFilter) select new HospitalSchedules { tbHospital = h, scheduleDataList = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doctorID && a.HospitalID == h.ID && a.AppointmentDatetime > now) .Where(hospitalSDfilter).OrderBy(a => a.AppointmentDatetime).ToList(), //.Where(appointmentDateFilter) }).DistinctBy(h => h.tbHospital.ID).ToList(); return(request.CreateResponse <List <HospitalSchedules> >(HttpStatusCode.OK, result)); }
public HttpResponseMessage UpsertDoctor(HttpRequestMessage request, tbHospital hospital) { string result = null; tbHospital UpdateEntity = null; if (hospital.Image != null) { result = iPhoto.uploadPhoto(hospital.Image); } else { result = null; } if (hospital.ID > 0) { if (hospital.Image == null) { tbHospital hos = dbContext.tbHospitals.Where(a => a.IsDeleted != true && a.ID == hospital.ID).FirstOrDefault(); hospital.Photo = hos.Photo; } else { hospital.Photo = result; } hospital.Image = null; UpdateEntity = hospitalRepo.UpdatewithObj(hospital); } else { hospital.Photo = result; hospital.Image = null; hospital.IsDeleted = false; hospital.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); UpdateEntity = hospitalRepo.AddWithGetObj(hospital); } return(request.CreateResponse <tbHospital>(HttpStatusCode.OK, UpdateEntity)); }
public bool checkBookingAvailable(int ScheduleDataID) { var result = false; var Now = MyExtension.getLocalTime(DateTime.UtcNow); using (var ctx = new CaremeDBContext()) { var scheduledata = ctx.tbScheduleDatas.Where(a => a.IsDeleted != true && a.ID == ScheduleDataID && a.IsStopped != true && a.IsCancelled != true).FirstOrDefault(); if (scheduledata != null) { if (scheduledata.AppointmentDatetime > Now) { int reachedPTCount = scheduledata.ReachedPatientCount ?? 0; int maxPTCount = scheduledata.MaxPatientCount ?? 0; int count = maxPTCount - reachedPTCount; if (count > 0) { result = true; } else { result = false; } } else { result = false; } } else { result = false; } } return(result); }
public HttpResponseMessage getNotiList(HttpRequestMessage request, int doctorid = 0) { List <NotiTimeFrameViewModel> NotiResultList = new List <NotiTimeFrameViewModel>(); DateTime TodayDate = MyExtension.getLocalTime(DateTime.UtcNow); NotiTimeFrameViewModel todayNotiObj = iScheduleService.scheduleNotis(TodayDate, doctorid, "Today"); DateTime yesterdayDate = TodayDate.AddDays(-1); NotiTimeFrameViewModel yesterdayNotiObj = iScheduleService.scheduleNotis(yesterdayDate, doctorid, "Yesterday"); if (todayNotiObj.Timeframe != null) { NotiResultList.Add(todayNotiObj); } if (yesterdayNotiObj.Timeframe != null) { NotiResultList.Add(yesterdayNotiObj); } return(request.CreateResponse <List <NotiTimeFrameViewModel> >(HttpStatusCode.OK, NotiResultList)); }
public HttpResponseMessage getData(HttpRequestMessage request, int doctorid = 0) { DoctorHomeViewModel homeObj = new DoctorHomeViewModel(); homeObj.doctorid = doctorid; homeObj.doctorName = doctorRepo.GetWithoutTracking().Where(a => a.ID == doctorid).Select(a => a.Name).FirstOrDefault(); DateTime localNow = MyExtension.getLocalTime(DateTime.UtcNow); using (CaremeDBContext context = new CaremeDBContext()) { string timeFrame_Today = "Today"; DateTime today = MyExtension.getLocalTime(DateTime.UtcNow); CountInTimeFrame today_Count = iScheduleService.hospitalSchedulesWithPatient(today, timeFrame_Today, doctorid); string timeFrame_Tomorrow = "Tomorrow"; DateTime tomorrow = today.AddDays(1); CountInTimeFrame tomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(tomorrow, timeFrame_Tomorrow, doctorid); DateTime DFtomorrow = today.AddDays(2); string timeFrame_DFTomorrow = DFtomorrow.Day + " " + DFtomorrow.ToString("MMM"); CountInTimeFrame DFtomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(DFtomorrow, timeFrame_DFTomorrow, doctorid); DateTime TDFtomorrow = today.AddDays(3); string timeFrame_TDFTomorrow = TDFtomorrow.Day + " " + TDFtomorrow.ToString("MMM"); CountInTimeFrame TDFtomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(TDFtomorrow, timeFrame_TDFTomorrow, doctorid); List <CountInTimeFrame> countInTimeframes = new List <CountInTimeFrame>(); countInTimeframes.Add(today_Count); countInTimeframes.Add(tomorrow_Count); countInTimeframes.Add(DFtomorrow_Count); countInTimeframes.Add(TDFtomorrow_Count); homeObj.CountList = countInTimeframes; return(request.CreateResponse <DoctorHomeViewModel>(HttpStatusCode.OK, homeObj)); } }
public HttpResponseMessage testtime(HttpRequestMessage request) { var datetime = MyExtension.getLocalTime(DateTime.UtcNow); return(request.CreateResponse <DateTime>(HttpStatusCode.OK, datetime)); }
public HttpResponseMessage UpsertDoctor(HttpRequestMessage request, DoctorSpecialityViewModel dsvm) { string result = null; tbDoctor UpdateEntity = null; if (dsvm.doctor.Image != null) { result = iPhoto.uploadPhoto(dsvm.doctor.Image); } else { result = null; } if (dsvm.doctor.ID > 0) { if (dsvm.doctor.Image == null) { tbDoctor doc = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == dsvm.doctor.ID).FirstOrDefault(); dsvm.doctor.Photo = doc.Photo; } else { dsvm.doctor.Photo = result; } dsvm.doctor.Image = null; dsvm.doctor.SpecialityID = dsvm.specialty.ID; dsvm.doctor.Specialty = dsvm.specialty.Specialty; UpdateEntity = doctorRepo.UpdatewithObj(dsvm.doctor); } else { dsvm.doctor.Photo = result; dsvm.doctor.Image = null; dsvm.doctor.SpecialityID = dsvm.specialty.ID; dsvm.doctor.Specialty = dsvm.specialty.Specialty; dsvm.doctor.IsDeleted = false; dsvm.doctor.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); UpdateEntity = doctorRepo.AddWithGetObj(dsvm.doctor); } tbDoctorHospital dh = doctorhospitalRepo.Get().Where(a => a.DoctorID == UpdateEntity.ID).FirstOrDefault(); if (dh != null) { dh.DoctorID = UpdateEntity.ID; dh.HospitalID = dsvm.hospitalid; dh.HospitalName = dsvm.hospitalname; dh.DoctorName = UpdateEntity.Name; doctorhospitalRepo.UpdatewithObj(dh); } else { dh = new tbDoctorHospital(); dh.DoctorID = UpdateEntity.ID; dh.HospitalID = dsvm.hospitalid; dh.HospitalName = dsvm.hospitalname; dh.DoctorName = UpdateEntity.Name; dh.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); dh.IsDeleted = false; doctorhospitalRepo.AddWithGetObj(dh); } dsvm.doctor = UpdateEntity; return(request.CreateResponse <DoctorSpecialityViewModel>(HttpStatusCode.OK, dsvm)); }
public HttpResponseMessage list(HttpRequestMessage request, int id = 0, string docname = null, DateTime?fromdate = null, DateTime?todate = null, int pagesize = 10, int page = 1, int hospitalid = 0) { Expression <Func <tbScheduleData, bool> > idfilter, fromtimefilter, totimefilter = null; Expression <Func <tbDoctorHospital, bool> > dochospitalfilter = null; Expression <Func <tbDoctor, bool> > docfilter = null; Expression <Func <tbHospital, bool> > hospitalFilter = null; if (hospitalid > 0) { hospitalFilter = h => h.ID == hospitalid; } else { hospitalFilter = h => h.IsDeleted != true; } if (id > 0) { idfilter = l => l.ID == id; } else { idfilter = l => l.IsDeleted != true; } if (docname != null) { dochospitalfilter = l => l.DoctorName.Contains(docname); } else { dochospitalfilter = l => l.IsDeleted != true; } if (docname != null) { docfilter = l => l.Name.Contains(docname); } else { docfilter = l => l.IsDeleted != true; } //if (fromtime != null) //{ // fromtimefilter = l => l.Fromtime == fromtime; //} //else //{ // fromtimefilter=l=>l.IsDeleted!=true; //} //if (totime != null) //{ // totimefilter = l => l.Totime == totime; //} //else //{ // totimefilter = l => l.IsDeleted != true; //} var today = MyExtension.getLocalTime(DateTime.UtcNow).Date; var nextsevendayfromtoday = today.AddDays(7); nextsevendayfromtoday = nextsevendayfromtoday.Date; List <ScheduleDoctorViewModel> result = null; var schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true).Where(a => a.AppointmentDatetime >= fromdate && a.AppointmentDatetime <= todate).ToList(); //var result1 = (from doc in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true && a.HospitalID == hospitalid) // join h in dbContext.tbHospitals.Where(a=>a.IsDeleted!= true).Where(hospitalFilter) on doc.HospitalID equals h.ID // join d in dbContext.tbHospitals.Where(a=>a.IsDeleted != true) on doc.DoctorID equals d.ID // join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true).Where(a => a.AppointmentDatetime >= fromdate && a.AppointmentDatetime <= todate) // on doc.DoctorID equals sch.DoctorID // select sch).ToList(); if (fromdate != null && todate != null) { fromdate = fromdate.Value.Date; todate = todate.Value.Date.AddDays(1); result = (from doc in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true && a.HospitalID == hospitalid) join h in dbContext.tbHospitals.Where(a => a.IsDeleted != true).Where(hospitalFilter) on doc.HospitalID equals h.ID join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true).Where(a => a.AppointmentDatetime >= fromdate && a.AppointmentDatetime <= todate) on doc.DoctorID equals sch.DoctorID join d in dbContext.tbDoctors.Where(a => a.IsDeleted != true).Where(docfilter) on sch.DoctorID equals d.ID select new ScheduleDoctorViewModel { doctor = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == d.ID).FirstOrDefault(), dochos = doc, schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == d.ID && a.HospitalID == doc.HospitalID).Where(a => a.AppointmentDatetime >= fromdate && a.AppointmentDatetime <= todate).ToList(), }).ToList().DistinctBy(a => a.doctor.ID).ToList(); } else { result = (from doc in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true && a.HospitalID == hospitalid).Where(dochospitalfilter) join h in dbContext.tbHospitals.Where(a => a.IsDeleted != true).Where(hospitalFilter) on doc.HospitalID equals h.ID join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true) on doc.DoctorID equals sch.DoctorID join d in dbContext.tbDoctors.Where(a => a.IsDeleted != true).Where(docfilter) on sch.DoctorID equals d.ID select new ScheduleDoctorViewModel { doctor = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == d.ID).FirstOrDefault(), dochos = doc, schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doc.DoctorID && a.AppointmentDatetime >= today && a.AppointmentDatetime <= nextsevendayfromtoday).ToList() }).DistinctBy(a => a.doctor.ID).ToList(); } var totalCount = result.Count(); var totalpages = (int)Math.Ceiling((double)totalCount / pagesize); var dataList = result.OrderBy(a => a.doctor.Name) .Skip(pagesize * (page - 1)).Take(pagesize); PagedListServer <ScheduleDoctorViewModel> model = new PagedListServer <ScheduleDoctorViewModel>(); model.Results = dataList.ToList(); model.TotalCount = totalCount; model.TotalPages = totalpages; dbContext.Dispose(); return(request.CreateResponse <PagedListServer <ScheduleDoctorViewModel> >(HttpStatusCode.OK, model)); // return request.CreateResponse<List<ScheduleDoctorViewModel>>(HttpStatusCode.OK, result); }
public HttpResponseMessage newstatuschange(HttpRequestMessage request, int id, string statuschange = null, int pagesize = 10, int page = 1) { // tbAppointment appointment = new tbAppointment(); tbAppointment UpdatedAppointment = null; tbAppointment appointment = appointmentRepo.Get().Where(a => a.ID == id).FirstOrDefault(); if (statuschange == "BOOKED") { appointment.Status = null; appointment.IsWaiting = true; appointment.IsApproved = true; } else if (statuschange == "WAITING") { appointment.Status = null; // appointment.IsWaiting = false; //updated appointment.IsCheckIn = true; } else if (statuschange == "CHECKIN") { // appointment.IsWaiting = false; //updated // appointment.IsCheckIn = false; appointment.Status = "CHECKOUT"; } else if (statuschange == "CANCEL") { appointment.Status = "CANCEL"; appointment.IsDelByAdmin = true; } else if (statuschange == "SKIP") { if (appointment.SkipCount == null) { appointment.SkipCount = 1; appointment.Position += 5; appointment.CreatedTime = MyExtension.getLocalTime(DateTime.UtcNow); } else { appointment.Status = "CANCEL"; appointment.IsDelByAdmin = true; } } UpdatedAppointment = appointmentRepo.UpdatewithObj(appointment); List <tbAppointment> result = appointmentRepo.Get().Where(a => a.Status != "CHECKOUT" && a.Status != "CANCEL").ToList(); //return request.CreateResponse<List<tbAppointment>>(HttpStatusCode.OK, appointments); var totalCount = result.Count(); var totalpages = (int)Math.Ceiling((double)totalCount / pagesize); var dataList = result.OrderBy(a => a.IsEmergency).OrderBy(a => a.Accesstime).OrderBy(a => a.Position) .Skip(pagesize * (page - 1)).Take(pagesize); PagedListServer <tbAppointment> model = new PagedListServer <tbAppointment>(); model.Results = dataList.ToList(); model.TotalCount = totalCount; model.TotalPages = totalpages; dbContext.Dispose(); return(request.CreateResponse <PagedListServer <tbAppointment> >(HttpStatusCode.OK, model)); }
public HttpResponseMessage Create(HttpRequestMessage request, PatientAppointmentViewModel patient) { PatientAppointmentViewModel pavm = new PatientAppointmentViewModel(); tbPatient UpdatedEntity = null; tbAppointment UpdatedAppointment = null; if (iBookingService.checkBookingAvailable(patient.appointment.ScheduleDataID ?? 0) == true) { if (patient.patient.ID > 0) { UpdatedEntity = patientRepo.UpdatewithObj(patient.patient); } else { if (patient.patient.MsgrID != null) { tbPatient oldPatient = patientRepo.Get().Where(a => a.MsgrID == patient.patient.MsgrID && a.IsDeleted != true).FirstOrDefault(); if (oldPatient != null) { oldPatient.MsgrName = patient.patient.MsgrName; oldPatient.Name = patient.patient.Name; oldPatient.Phone = patient.patient.Phone; oldPatient.Problem = patient.patient.Problem; oldPatient.Gender = patient.patient.Gender; oldPatient.Age = patient.patient.Age; oldPatient.Address = patient.patient.Address; UpdatedEntity = patientRepo.UpdatewithObj(oldPatient); } else { // UpdatedEntity = new tbPatient(); patient.patient.IsDeleted = false; patient.patient.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); UpdatedEntity = patientRepo.AddWithGetObj(patient.patient); } } else { // UpdatedEntity = new tbPatient(); patient.patient.IsDeleted = false; patient.patient.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); UpdatedEntity = patientRepo.AddWithGetObj(patient.patient); } } tbAppointment appointment = appRepo.GetWithoutTracking().Where(a => a.IsDeleted != true && a.PatientId == UpdatedEntity.ID).FirstOrDefault(); if (appointment != null) { appointment.PatientId = UpdatedEntity.ID; appointment.PatientName = UpdatedEntity.Name; appointment.PatientAge = UpdatedEntity.Age; appointment.DoctorName = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == patient.appointment.DoctorId).Select(a => a.Name).FirstOrDefault(); appointment = appRepo.UpdatewithObj(appointment); } else { var scheduledata = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.ID == patient.appointment.ScheduleDataID).FirstOrDefault(); int counter = dbContext.tbAppointments.Where(a => a.ScheduleDataID == scheduledata.ID).Count(); int?position = dbContext.tbAppointments.Where(a => a.ScheduleDataID == scheduledata.ID).Max(a => a.Position); // patient.appointment = new tbAppointment(); patient.appointment.PatientId = UpdatedEntity.ID; patient.appointment.PatientName = UpdatedEntity.Name; patient.appointment.PatientAge = UpdatedEntity.Age; patient.appointment.Status = "BOOKED"; patient.appointment.Counter = counter + 1; if (position == null) { patient.appointment.Position = counter + 1; } else { patient.appointment.Position = position + 1; } //patient.appointment.HospitalId = //patient.appointment.HospitalName = // patient.appointment.Day = patient.appointment.AppointmentDateTime.Value.DayOfWeek.ToString(); patient.appointment.IsDeleted = false; patient.appointment.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow); patient.appointment.HospitalName = dbContext.tbHospitals.Where(a => a.IsDeleted != true && a.ID == patient.appointment.HospitalId).Select(a => a.Name).FirstOrDefault(); // patient.appointment.DoctorName = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == patient.appointment.DoctorId).Select(a => a.Name).FirstOrDefault(); UpdatedAppointment = appRepo.AddWithGetObj(patient.appointment); var doc = docRepo.Get().Where(a => a.ID == patient.appointment.DoctorId && a.IsDeleted != true).FirstOrDefault(); FCMViewModel fcm = new FCMViewModel(); fcm.to = doc.UserToken; fcmdata fcmdata = new fcmdata(); fcmdata.body = "1 patient is waiting"; fcmdata.doctorId = doc.ID; fcmdata.title = "Booking notification"; fcmdata.type = "1001"; fcm.data = fcmdata; FCMRequestHelper.sendTokenMessage(fcm); } } pavm.patient = UpdatedEntity; pavm.appointment = UpdatedAppointment; return(request.CreateResponse <PatientAppointmentViewModel>(HttpStatusCode.OK, pavm)); }
public HttpResponseMessage list(HttpRequestMessage request, int docid = 0, int specialityid = 0, string docname = null, DateTime?datetime = null, DateTime?fromtime = null, DateTime?totime = null, int pagesize = 5, int page = 1, int hospitalid = 0) { Expression <Func <tbScheduleData, bool> > datetimefilter, fromtimefilter, totimefilter = null; Expression <Func <tbDoctor, bool> > specialityidfilter, docnamefilter, idfilter = null; if (docid > 0) { idfilter = l => l.ID == docid; } else { idfilter = l => l.IsDeleted != true; } if (specialityid > 0) { specialityidfilter = l => l.SpecialityID == specialityid; } else { specialityidfilter = l => l.IsDeleted != true; } if (docname != null) { docnamefilter = l => l.Name.Contains(docname); } else { docnamefilter = l => l.IsDeleted != true; } if (datetime != null) { datetimefilter = l => l.AppointmentDatetime == datetime; } else { datetimefilter = l => l.IsDeleted != true; } if (fromtime != null) { fromtimefilter = l => l.Fromtime == fromtime; } else { fromtimefilter = l => l.IsDeleted != true; } if (totime != null) { totimefilter = l => l.Totime == totime; } else { totimefilter = l => l.IsDeleted != true; } List <ScheduleBookingViewModel> result = null; if (datetime == null) { var today = MyExtension.getLocalTime(DateTime.UtcNow).Date; //var result = (from doc in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true) // join d in dbContext.tbDoctors.Where(a => a.IsDeleted != true) on doc.DoctorID equals d.ID // join h in dbContext.tbHospitals.Where(a => a.IsDeleted != true && a.ID == hospitalid) on doc.DoctorID equals h.ID // join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.AppointmentDatetime.Value.Day == datetime.Value.Day && a.HospitalID == hospitalid) // on doc.ID equals sch.DoctorID // select new ScheduleDoctorViewModel // { // doctor = d, // schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doc.ID).ToList(), // }).DistinctBy(a => a.doctor.ID).ToList(); result = (from doh in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true) // join h in dbContext.tbHospitals.Where(a=>a.IsDeleted != true) on doh.HospitalID equals h.ID join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.HospitalID == hospitalid) on doh.DoctorID equals sch.DoctorID join doc in dbContext.tbDoctors.Where(a => a.IsDeleted != true) .Where(idfilter).Where(specialityidfilter).Where(docnamefilter) on sch.DoctorID equals doc.ID select new ScheduleBookingViewModel { doctor = doc, schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doc.ID && a.HospitalID == hospitalid).ToList(), }).DistinctBy(a => a.doctor.ID).ToList(); } else { result = (from doh in dbContext.tbDoctorHospitals.Where(a => a.IsDeleted != true) //join h in dbContext.tbHospitals.Where(a => a.IsDeleted != true) on doh.HospitalID equals h.ID join sch in dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.AppointmentDatetime.Value.Day == datetime.Value.Day) on doh.DoctorID equals sch.DoctorID join doc in dbContext.tbDoctors.Where(a => a.IsDeleted != true) .Where(idfilter).Where(specialityidfilter).Where(docnamefilter) on doh.DoctorID equals doc.ID select new ScheduleBookingViewModel { doctor = doc, schedule = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doc.ID).ToList(), }).DistinctBy(a => a.doctor.ID).ToList(); } var totalCount = result.Count(); var totalpages = (int)Math.Ceiling((double)totalCount / pagesize); var dataList = result.OrderBy(a => a.doctor.Name).Skip(pagesize * (page - 1)).Take(pagesize); PagedListServer <ScheduleBookingViewModel> model = new PagedListServer <ScheduleBookingViewModel>(); model.Results = dataList.ToList(); model.TotalCount = totalCount; model.TotalPages = totalpages; dbContext.Dispose(); return(request.CreateResponse <PagedListServer <ScheduleBookingViewModel> >(HttpStatusCode.OK, model)); }