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> 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 void CreateLogin(int userId) { var newLogin = new Login(); newLogin.Login1 = DateTime.Now; newLogin.Logout = default; newLogin.Status = "login"; newLogin.UserId = userId; newLogin.CreatedAt = DateTime.Now; newLogin.UpdatedAt = DateTime.Now; _context.Add(newLogin); }
public async Task <IActionResult> Create([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 (ModelState.IsValid) { _context.Add(tracking); await _context.SaveChangesAsync(); 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 async Task <IActionResult> Refer([Bind] ReferPatientViewModel model) { var currentPatient = _context.Patient.Find(model.PatientId); model.ReferredToMd = model.ReferredToMd == 0 ? null : model.ReferredToMd; if (ModelState.IsValid && model.ReferredTo != 0 && model.Department != 0) { var patient = setNormalPatientForm(model); var tracking = setNormalTracking(patient); var activity = SetNormalActivity(tracking); _context.Add(tracking); _context.Add(activity); _context.Add(patient); await _context.SaveChangesAsync(); return(RedirectToAction("ListPatients", "ViewPatients")); } else { ModelState.AddModelError("ReferredTo", "Please select a Facility."); ModelState.AddModelError("Department", "Please select a Department."); } var facility = _context.Facility.Single(x => x.Id.Equals(UserFacility())); var patientView = new PatientViewModel { Id = currentPatient.Id, Name = GlobalFunctions.GetFullName(currentPatient), Age = GlobalFunctions.ComputeAge(currentPatient.DateOfBirth), Sex = currentPatient.Sex, CivilStatus = currentPatient.CivilStatus, Address = GlobalFunctions.GetAddress(currentPatient), PhicStatus = currentPatient.PhicStatus, PhicId = currentPatient.PhicId }; var referTo = _context.Facility .Where(x => x.Id != UserFacility()) .Where(x => x.ProvinceId.Equals(UserProvince())); ViewBag.ReferredTo = new SelectList(referTo, "Id", "Name", model.ReferredTo); ViewBag.Patient = patientView; ViewBag.Facility = facility.Name; ViewBag.FacilityAddress = GlobalFunctions.GetAddress(facility); return(PartialView(model)); }