public async Task <IActionResult> Create(PatientExaminationViewModel patientExamVM) { try { if (ModelState.IsValid) { int id = await PatientsHelper.AddPatientExAsync(patientExamVM); await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } return(RedirectToAction(nameof(Details), new { id = id })); } } catch (DbUpdateException) { //Log the error ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction(nameof(Create), new { id = patientExamVM.PatientID })); }
public async Task <IActionResult> DeleteConfirmed(int id) { try { await PatientsHelper.DeleteAsync(id); return(RedirectToAction(nameof(Index))); } catch (DbUpdateException) { return(RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true })); } }
// GET: Patients/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } PatientViewModel patient = await PatientsHelper.GetPatientByIdAsync((int)id); if (patient == null) { return(NotFound()); } return(View(patient)); }
// GET: PatientExaminations/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } PExaminationViewModel patientExamination = await PatientsHelper.GetPExaminationByIdAsync((int)id); if (patientExamination == null) { return(NotFound()); } return(View(patientExamination)); }
public async Task <IActionResult> Create(PatientViewModel patientVM) { try { if (ModelState.IsValid) { await PatientsHelper.AddPatientAsync(patientVM); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException) { //Log the error ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(patientVM)); }
// GET: Patients/Delete/5 public async Task <IActionResult> Delete(int?id, bool?saveChangesError = false) { if (id == null) { return(NotFound()); } PatientViewModel patient = await PatientsHelper.GetPatientByIdAsync((int)id); if (patient == null) { return(NotFound()); } if (saveChangesError.GetValueOrDefault()) { ViewData["ErrorMessage"] = "Delete failed. Try again, and if the problem persists " + "see your system administrator."; } return(View(patient)); }
public async Task <IActionResult> DeleteConfirmed(int id) { try { await PatientsHelper.CancelPatientExAsync(id); await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } return(RedirectToAction(nameof(Index))); } catch (DbUpdateException) { return(RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true })); } }
public async Task <IActionResult> EditPost(int?id, PatientViewModel patientVM) { if (id == null || id != patientVM.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await PatientsHelper.UpdatePatientAsync((int)id, patientVM); return(RedirectToAction(nameof(Index))); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } } return(View(patientVM)); }
// GET: PatientExaminations/Create public async Task <IActionResult> Create(int?id) { ViewBag.Examinations = _context.Examinations.Select(e => new SelectListItem() { Value = e.ID.ToString(), Text = e.ExCode + " | " + e.Name }); if (id == null) { ViewBag.Patients = _context.Patients.Select(p => new SelectListItem() { Value = p.ID.ToString(), Text = p.InsuranceNumber + " | " + p.LastName + ", " + p.FirstName }); return(View()); } else { PatientExaminationViewModel patientExamination = await PatientsHelper.GetPatientExByIdAsync((int)id); return(View(patientExamination)); } }
// GET: Patients public async Task <IActionResult> Index() { return(View(await PatientsHelper.GetPatientsListAsync())); }
public PatientsController(MLabContext context) { _context = context; PatientsHelper.Init(_context); }
// GET: PatientExaminations public async Task <IActionResult> Index(bool pending = false) { return(View(await PatientsHelper.GetPExaminations(pending))); }
public PatientExaminationsController(MLabContext context, IApplicationData applicationData) { _context = context; appData = applicationData; PatientsHelper.Init(_context); }