public async Task<IActionResult> PatientForm(string code) { if (code == null) return NotFound(); var patientForm = _context.PatientForm.Single(x => x.Code.Equals(code)); if (patientForm == null) return NotFound(); var tracking = _context.Tracking.Single(x => x.Code.Equals(code)); var activity = _context.Activity.Single(x => x.Code.Equals(code) && x.Status.Equals(_status.Value.REFERRED)); if (!activity.Status.Equals(_status.Value.REFERRED)) activity.Status = _status.Value.REFERRED; tracking.DateSeen = DateTime.Now; activity.DateSeen = DateTime.Now; _context.Update(tracking); _context.Update(activity); var seen = new Seen(); seen.FacilityId = UserFacility(); seen.TrackingId = _context.Tracking.Single(x => x.Code.Equals(patientForm.Code)).Id; seen.UpdatedAt = DateTime.Now; seen.CreatedAt = DateTime.Now; seen.UserMd = UserId(); _context.Add(seen); await _context.SaveChangesAsync(); return PartialView(patientForm); }
public async Task <IActionResult> Travel([Bind] TravelViewModel model) { if (ModelState.IsValid) { var tracking = TravelTracking(model); var activity = TravelActivity(tracking); _context.Update(tracking); _context.Add(activity); await _context.SaveChangesAsync(); return(RedirectToAction("Referred", "ViewPatients")); } return(PartialView()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Code,PatientId,DateReferred,DateTransferred,DateAccepted,DateArrived,DateSeen,Transportation,ReferredFrom,ReferredTo,DepartmentId,ReferringMd,ActionMd,Remarks,Status,Type,WalkIn,FormId,CreatedAt,UpdatedAt")] Tracking tracking) { if (id != tracking.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tracking); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrackingExists(tracking.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ActionMd"] = new SelectList(_context.User, "Id", "Contact", tracking.ActionMd); ViewData["DepartmentId"] = new SelectList(_context.Department, "Id", "Description", tracking.DepartmentId); ViewData["PatientId"] = new SelectList(_context.Patient, "Id", "CivilStatus", tracking.PatientId); ViewData["ReferredFrom"] = new SelectList(_context.Facility, "Id", "Id", tracking.ReferredFrom); ViewData["ReferredTo"] = new SelectList(_context.Facility, "Id", "Id", tracking.ReferredTo); ViewData["ReferringMd"] = new SelectList(_context.User, "Id", "Contact", tracking.ReferringMd); return(View(tracking)); }
public void ChangeLoginStatus(string status) { var currentUser = _context.User.Find(UserId()); if (status.Equals("onDuty")) { currentUser.LoginStatus = "login"; } else if (status.Equals("offDuty")) { currentUser.LoginStatus = "login off"; } currentUser.UpdatedAt = DateTime.Now; _context.Update(currentUser); _context.SaveChangesAsync(); }