Beispiel #1
0
        public ActionResult PatientRegister(PatientRegisterViewModel patientView)
        {
            if (ModelState.IsValid)
            {
                var patient = new Patient()
                {
                    FirstName          = patientView.FirstName,
                    LastName           = patientView.LastName,
                    Age                = patientView.Age,
                    PhoneNo            = patientView.PhoneNo,
                    Sex                = patientView.Sex,
                    UserId             = patientView.UserId,
                    Password           = patientView.Password,
                    RegistrationStatus = false
                };
                _context.Patients.Add(patient);
                _context.SaveChanges();

                return(View());
            }
            else
            {
                return(View("Error"));
            }
        }
Beispiel #2
0
        public IActionResult RegisterPatient(PatientRegisterViewModel model)
        {
            if(ModelState.IsValid)
            {
                string sMonth = DateTime.Now.ToString("MM");
                string sDay = DateTime.Now.ToString("dd");
                DateTime todaysDate = DateTime.Now.Date;
                int year = todaysDate.Year;



                var patient = new Patient
                {
                    Name = model.patient.Name,
                    Address = model.patient.Address,
                    Phone = model.patient.Phone,
                    BirthDate = model.patient.BirthDate,
                    Height = model.patient.Height,
                    Weight = model.patient.Weight,
                    GenderId = model.patient.GenderId,
                    Token = (year + sMonth + sDay + _unitOfWork.Patient.GetPatients().Count()).ToString(),

                };
                _unitOfWork.Patient.Add(patient);
                _unitOfWork.Complete();
                return RedirectToAction("Index","Home");
            }
            return View();
        }
Beispiel #3
0
        public IActionResult Register(PatientRegisterViewModel model, ConceptService cs)
        {
            CoreService service = new CoreService(HttpContext);

            model.Facilities = service.GetFacilitiesIEnumerable();

            model.TBCategory        = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_CATEGORY));
            model.TBTypes           = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_TYPE));
            model.TBConfirmation    = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_CONFIRMATION));
            model.ResistanceProfile = cs.GetConceptAnswersIEnumerable(new Concept(Constants.RESISTANCE_PROFILE));

            return(View(model));
        }
Beispiel #4
0
        public async Task <IActionResult> Update(string returnUrl = null)
        {
            var model = new PatientRegisterViewModel();
            var user  = (PatientUser)await _userManager.GetUserAsync(HttpContext.User);

            model.FirstName       = user.FirstName;
            model.LastName        = user.LastName;
            model.ZipCode         = user.ZipCode;
            model.Sex             = user.Sex;
            model.Insurance       = user.Insurance;
            model.PhoneNumber     = user.PhoneNumber;
            model.UserPhoto       = model.UserPhoto;
            ViewData["ReturnUrl"] = "/Patient/Profile";
            return(View(model));
        }
Beispiel #5
0
        public IActionResult RegisterPatient()
        {

            var ViewModel = new PatientRegisterViewModel();
            var genders = _unitOfWork.Gender.GetGenders();
            foreach(var gender in genders)
            {
                ViewModel.GenderList.Add(new SelectListItem()
                {
                    Value = gender.GenderId.ToString(),
                    Text = gender.GenderName
                }
                    
                    );
            }
            return View(ViewModel);
        }
Beispiel #6
0
        public IActionResult Enroll(string p, PatientRegisterViewModel model, ConceptService cs)
        {
            model.Patient          = new PatientService(HttpContext).GetPatient(p);
            model.Program.Category = new Concept(Constants.RELAPSE);

            if (model.Patient.isDead())
            {
                return(LocalRedirect("/patients/profile/" + model.Patient.GetUuid()));
            }

            model.Facilities        = new CoreService(HttpContext).GetFacilitiesIEnumerable();
            model.TBCategory        = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_CATEGORY));
            model.TBTypes           = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_TYPE));
            model.TBConfirmation    = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TB_CONFIRMATION));
            model.ResistanceProfile = cs.GetConceptAnswersIEnumerable(new Concept(Constants.RESISTANCE_PROFILE));

            return(View(model));
        }
Beispiel #7
0
        public async Task <IActionResult> Update(PatientRegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = "/Patient/Profile";
            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            var DBuser = _context.Patients.SingleOrDefault(u => u.Id == currentUser.Id);

            if (DBuser != null)
            {
                if (DBuser.FirstName != model.FirstName || DBuser.LastName != model.LastName)
                {
                    var messages = (from message in _context.Messages
                                    where message.PatientID == currentUser.Id select message).ToList();

                    foreach (Message m in messages)
                    {
                        m.PatientName = model.FirstName + " " + model.LastName;
                    }
                }

                DBuser.FirstName   = model.FirstName;
                DBuser.LastName    = model.LastName;
                DBuser.ZipCode     = model.ZipCode;
                DBuser.Sex         = model.Sex;
                DBuser.Insurance   = model.Insurance;
                DBuser.PhoneNumber = model.PhoneNumber;
                using (var memoryStream = new MemoryStream())
                {
                    if (model.UserPhoto != null)
                    {
                        await model.UserPhoto.CopyToAsync(memoryStream);

                        DBuser.UserPhoto = memoryStream.ToArray();
                    }
                }

                _context.SaveChanges();
                return(Redirect("/Patient/Profile"));
            }
            return(View(model));
        }
Beispiel #8
0
        public IActionResult Edit(PatientRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {


                var patientObj = _unitOfWork.Patient.GetPatientById(model.patient.Id);
                patientObj.Name = model.patient.Name;
                patientObj.Address = model.patient.Address;
                patientObj.Phone = model.patient.Phone;
                patientObj.GenderId = model.patient.GenderId;
                patientObj.Weight = model.patient.Weight;
                patientObj.Height = model.patient.Height;
                patientObj.BirthDate = model.patient.BirthDate;

                /*                _unitOfWork.Patient.Update(model.patient);*/
                _unitOfWork.Complete();

            }
            return RedirectToAction("Details", "Patient", new { @id = model.patient.Id });
             return RedirectToAction(nameof(Index));

        }
        public async Task <IActionResult> PatientRegister(PatientRegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = new PatientUser {
                    FirstName = model.FirstName, LastName = model.LastName, UserName = model.Email, Email = model.Email, DateOfBirth = model.DateOfBirth,
                    ZipCode   = model.ZipCode, Ethnicity = model.Ethnicity, Sex = model.Sex, AccountType = "Patient", Insurance = model.Insurance, PhoneNumber = model.PhoneNumber
                };
                using (var memoryStream = new MemoryStream())
                {
                    await model.UserPhoto.CopyToAsync(memoryStream);

                    user.UserPhoto = memoryStream.ToArray();
                }
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                    await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    _logger.LogInformation("User created a new account with password.");
                    return(RedirectToLocal(returnUrl));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #10
0
        public IActionResult Edit (int id)
        {
            var patientDetails = _unitOfWork.Patient.GetPatientById(id);

            var model = new PatientRegisterViewModel
            {
                patient = patientDetails,

            };
            
            var genders = _unitOfWork.Gender.GetGenders();
            foreach (var gender in genders)
            {
                model.GenderList.Add(new SelectListItem()
                {
                    Value = gender.GenderId.ToString(),
                    Text = gender.GenderName
                }

                    );
            }

            return View(model);
        }