public async Task <ActionResult <JsonR> > changeStatus(long ReceptionId, int IdWaiting)//,string comment="") { string today = MYHelper.PersianDate(MYHelper.GetDate()); DateTime from = MYHelper.DiffDate(today, true).AddDays(-7); DateTime to = MYHelper.DiffDate(today, false); JsonR result; var lst = repository.GetAll().Result; tblVisit model = lst.FirstOrDefault(c => c.IdReception == ReceptionId && c.VisitDate >= from && c.VisitDate <= to); if (model == null) { result = new JsonR { Title = "error", Message = "ویزیت به تاریخ امروز وجود ندارد" }; return(result); } model.IdWaiting = IdWaiting; ContextDb db = new ContextDb(); db.tblReceptions.Find(ReceptionId).IdWaiting = IdWaiting; //if (!string.IsNullOrEmpty(comment)) // model.Comment = comment; db.SaveChanges(); result = new JsonR { Title = "success", Message = "عملیات با موفقیت انجام شد" }; return(result); }
public async Task <ActionResult <tblVisit> > Get(long idreception, DateTime date) { var tblVisit = await repository.Get(c => c.IdReception == idreception && c.VisitDate == date); if (tblVisit == null) { return(NotFound()); } tblVisit.FarsiDate = MYHelper.PersianDate(tblVisit.VisitDate); return(tblVisit); }
public IEnumerable <string> getyear() { var lst = repository.GetAll().Result; List <string> lstyear = new List <string>(); foreach (DateTime item in lst.Select(c => c.VisitDate).OrderByDescending(c => c)) { lstyear.Add(MYHelper.PersianDate(item).Substring(0, 4)); } return(lstyear.Distinct()); }
public async Task <ActionResult <tblReception> > Get(long id) { var tblReception = await repository.Get(id); if (tblReception == null) { return(NotFound()); } using (ContextDb db = new ContextDb()) { tblReception.tbl_patient = db.tbl_patient.Find(tblReception.IdPatient); var lstvisit = db.tblVisits.Where(c => c.IdReception == tblReception.Id).ToList(); lstvisit.ForEach(c => c.FarsiDate = MYHelper.PersianDate(c.VisitDate)); tblReception.tblVisits = lstvisit; } return(tblReception); }
public IActionResult GetAll(string fromdate, string todate, int?idService) { fromdate = fromdate.Replace('_', '/'); todate = todate.Replace('_', '/'); DateTime from = MYHelper.DiffDate(fromdate, true); DateTime to = MYHelper.DiffDate(todate, false); ContextDb db = new ContextDb(); var qq = repository.GetAll(c => c.VisitDate >= from && c.VisitDate <= to && (idService.HasValue ? (c.tblReception.IdService == idService) : true) ).Result; List <reportvisit_result> result = new List <reportvisit_result>(); int i = 0; foreach (var item in qq) { i++; var reception = db.tblReceptions.Find(item.IdReception); var service = db.tbl_Service.Find(reception.IdService); var patient = db.tbl_patient.Find(reception.IdPatient); result.Add(new reportvisit_result { Comment = item.Comment, Dossier = patient.DossierNumberPermanent, FullName = patient.Name + ' ' + patient.LastName, Payment = item.FreePrices, PersianDate = MYHelper.PersianDate(item.VisitDate), service = service.Name, Tel = patient.Tel, total = item.TotalMeeting, Row = i }); } return(Ok(result)); }
public IActionResult GetAll(string LName, string fromdate, string todate) { fromdate = fromdate.Replace('_', '/'); todate = todate.Replace('_', '/'); ContextDb db = new ContextDb(); IEnumerable <GetVisitListResult> lst; if (!string.IsNullOrEmpty(LName)) { lst = db.tblVisits.Join(db.tblReceptions.Where(c => c.tbl_patient.LastName.Contains(LName)), c => c.IdReception, d => d.Id, (c, d) => new GetVisitListResult { Tel = d.tbl_patient.Tel, service = d.tbl_Service.Name, ReceptionId = c.IdReception, VisitCurrentId = c.Id, patientId = d.IdPatient, DateCurrent = c.VisitDate, IdWaitingVisitCurrent = c.IdWaiting, FullName = d.tbl_patient.Name + " " + d.tbl_patient.LastName, DossierNumberPermanent = d.tbl_patient.DossierNumberPermanent }); } else { if (string.IsNullOrEmpty(fromdate)) { lst = db.tblVisits.Join(db.tblReceptions, c => c.IdReception, d => d.Id, (c, d) => new GetVisitListResult { Tel = d.tbl_patient.Tel, service = d.tbl_Service.Name, ReceptionId = c.IdReception, patientId = d.IdPatient, VisitCurrentId = c.Id, IdWaitingVisitCurrent = c.IdWaiting, DateCurrent = c.VisitDate, FullName = d.tbl_patient.Name + " " + d.tbl_patient.LastName, DossierNumberPermanent = d.tbl_patient.DossierNumberPermanent }); } else { DateTime from = MYHelper.DiffDate(fromdate, true); DateTime to = MYHelper.DiffDate(todate, false); lst = db.tblVisits.Where(c => c.VisitDate >= from && c.VisitDate <= to).Join(db.tblReceptions, c => c.IdReception, d => d.Id, (c, d) => new GetVisitListResult { Tel = d.tbl_patient.Tel, service = d.tbl_Service.Name, ReceptionId = c.IdReception, VisitCurrentId = c.Id, patientId = d.IdPatient, DateCurrent = c.VisitDate, IdWaitingVisitCurrent = c.IdWaiting, FullName = d.tbl_patient.Name + " " + d.tbl_patient.LastName, DossierNumberPermanent = d.tbl_patient.DossierNumberPermanent }); } } lst = lst.GroupBy(d => d.ReceptionId).Select(d => new GetVisitListResult { Tel = d.FirstOrDefault().Tel, service = d.FirstOrDefault().service, ReceptionId = d.Key, DateCurrent = d.OrderBy(z => z.DateCurrent).FirstOrDefault().DateCurrent, VisitCurrentId = d.OrderBy(z => z.DateCurrent).FirstOrDefault().VisitCurrentId, patientId = d.FirstOrDefault().patientId, IdWaitingVisitCurrent = d.OrderBy(z => z.DateCurrent).FirstOrDefault().IdWaitingVisitCurrent, FullName = d.FirstOrDefault().FullName, DossierNumberPermanent = d.FirstOrDefault().DossierNumberPermanent }); lst = lst.Distinct().ToList(); foreach (var item in lst) { var lstvisit = db.tblVisits.Where(c => c.IdReception == item.ReceptionId).OrderBy(c => c.VisitDate).ToList();//.Select(c => c.PersianDate); for (int i = 1; i <= lstvisit.Count(); i++) { tblVisit visit = lstvisit.Skip((i - 1)).Take(1).FirstOrDefault(); switch (i) { case 1: item.Date1 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting1 = visit.IdWaiting; break; case 2: item.Date2 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting2 = visit.IdWaiting; break; case 3: item.Date3 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting3 = visit.IdWaiting; break; case 4: item.Date4 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting4 = visit.IdWaiting; break; case 5: item.Date5 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting5 = visit.IdWaiting; break; case 6: item.Date6 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting6 = visit.IdWaiting; break; case 7: item.Date7 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting7 = visit.IdWaiting; break; case 8: item.Date8 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting8 = visit.IdWaiting; break; case 9: item.Date9 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting9 = visit.IdWaiting; break; case 10: item.Date10 = MYHelper.PersianDate(visit.VisitDate); item.IdWaiting10 = visit.IdWaiting; break; default: break; } } } return(Ok(lst)); }