Example #1
0
        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> SwitchUser([Bind] SwitchUserModel model)
        {
            var users = _context.User
                        .Where(x => x.FacilityId.Equals(UserFacility()))
                        .Select(x => new ChangeLoginViewModel
            {
                Id           = x.Id,
                UserLastname = x.Lastname + ", " + x.Firstname
            });

            if (ModelState.IsValid)
            {
                var(isValid, user) = await _userService.SwitchUserAsync(model.Id, model.Password);

                if (isValid)
                {
                    await ChangeUser();
                    await LoginAsync(user, false);

                    CreateLogin(user.Id);

                    await _context.SaveChangesAsync();

                    if (user.Level.Equals(_roles.Value.ADMIN))
                    {
                        return(RedirectToAction("AdminDashboard", "Admin"));
                    }
                    else if (user.Level.Equals(_roles.Value.DOCTOR))
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                    else if (user.Level.Equals(_roles.Value.SUPPORT))
                    {
                        return(RedirectToAction("SupportDashboard", "Support"));
                    }
                    else if (user.Level.Equals(_roles.Value.MCC))
                    {
                        return(RedirectToAction("MccDashboard", "MedicalCenterChief"));
                    }
                }
                else
                {
                    ModelState.AddModelError("Password", "Wrong Password.");
                }
            }
            ViewBag.Users = new SelectList(users, "Id", "UserLastname", UserId());
            return(PartialView("~/Views/Account/SwitchUser.cshtml", model));
        }
Example #3
0
        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));
        }
Example #4
0
        public async Task <IActionResult> Add([Bind] Patient patient)
        {
            patient.ProvinceId = UserProvince();
            if (ModelState.IsValid)
            {
                setPatients(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ListPatients", "ViewPatients", new { name = patient.FirstName, muncityId = patient.MuncityId, barangayId = patient.BarangayId }));
            }
            ViewBag.BarangayId  = new SelectList(_context.Barangay, "Id", "Description", patient.BarangayId);
            ViewBag.MuncityId   = new SelectList(_context.Muncity, "Id", "Description", patient.MuncityId);
            ViewBag.ProvinceId  = new SelectList(_context.Province, "Id", "Description", patient.ProvinceId);
            ViewBag.CivilStatus = new SelectList(ListContainer.CivilStatus, patient.CivilStatus);
            ViewBag.PhicStatus  = new SelectList(ListContainer.PhicStatus, patient.PhicStatus);
            return(View(patient));
        }
        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();
        }
Example #6
0
 public void ViewReco([Bind] FeedbackViewModel model)
 {
     if (ModelState.IsValid)
     {
         var feedback = new Feedback
         {
             Code       = model.Code,
             SenderId   = model.MdId,
             RecieverId = null,
             Message    = model.Message,
             CreatedAt  = DateTime.Now,
             UpdatedAt  = DateTime.Now
         };
         _context.AddAsync(feedback);
         _context.SaveChangesAsync();
     }
 }
Example #7
0
        public async Task <IActionResult> Chat([Bind] FeedbackViewModel model)
        {
            if (ModelState.IsValid)
            {
                var chat = new Feedback
                {
                    Code       = model.Code,
                    SenderId   = model.MdId,
                    RecieverId = null,
                    Message    = model.Message,
                    UpdatedAt  = DateTime.Now,
                    CreatedAt  = DateTime.Now
                };
                await _context.AddAsync(chat);

                await _context.SaveChangesAsync();
            }
            ;

            return(View());
        }
Example #8
0
        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());
        }