Exemplo n.º 1
0
        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 }));
        }
Exemplo n.º 2
0
        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 }));
            }
        }
Exemplo n.º 3
0
        // 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));
        }
Exemplo n.º 4
0
        // 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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        // 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));
        }
Exemplo n.º 7
0
        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 }));
            }
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        // 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));
            }
        }
Exemplo n.º 10
0
 // GET: Patients
 public async Task <IActionResult> Index()
 {
     return(View(await PatientsHelper.GetPatientsListAsync()));
 }
Exemplo n.º 11
0
 public PatientsController(MLabContext context)
 {
     _context = context;
     PatientsHelper.Init(_context);
 }
Exemplo n.º 12
0
 // GET: PatientExaminations
 public async Task <IActionResult> Index(bool pending = false)
 {
     return(View(await PatientsHelper.GetPExaminations(pending)));
 }
Exemplo n.º 13
0
 public PatientExaminationsController(MLabContext context, IApplicationData applicationData)
 {
     _context = context;
     appData  = applicationData;
     PatientsHelper.Init(_context);
 }