public ActionResult Add(AddPatientViewModel addPatientInputModel) { if (ModelState.IsValid) { var patient = new Patient { Title = addPatientInputModel.Title.ToString(), Name = addPatientInputModel.Name, DateOfBirth = addPatientInputModel.DateOfBirth.Value, NHSNumber = addPatientInputModel.NHSNumber, ConsultantName = addPatientInputModel.ConsultantName, ConsultantNumber = addPatientInputModel.ConsultantNumber }; using (var unitOfwork = new UnitOfWork()) { patient.ValidationFailed += ruleViolation => { ruleViolation.CreatedAt = DateTime.UtcNow; unitOfwork.RuleViolations.Add(ruleViolation); }; patient.Validate(); unitOfwork.Patients.Add(patient); unitOfwork.SaveChanges(); } return(RedirectToAction("Add")); } addPatientInputModel.AllPatients = GetAllPatients(); return(View(addPatientInputModel)); }
private async Task <User> AddUser(AddPatientViewModel view) { var user = new User { Document = view.Document, Email = view.Username, FirstName = view.FirstName, LastName = view.LastName, PhoneNumber = view.PhoneNumber, UserName = view.Username, DateBirth = view.DateBirth, FathersEmail = view.FathersEmail, CanEdit = false, }; var result = await _userHelper.AddUserAsync(user, view.Password); if (result != IdentityResult.Success) { return(null); } var newUser = await _userHelper.GetUserByEmailAsync(view.Username); await _userHelper.AddUserToRoleAsync(newUser, "Patient"); return(newUser); }
public async Task <IActionResult> AddPatient(AddPatientViewModel input) { string password = "******"; var roleName = "Patient"; var user = administratorService.CreatePatient(input.FirstName, input.LastName, input.Email, input.BirthDate, input.Address, input.Town, input.PhoneNumber, input.Email); var patient = await userManager.CreateAsync(user, password); if (!patient.Succeeded) { //var token = await userManager.GenerateEmailConfirmationTokenAsync(createPatient); //var confirmationLink = Url.Action("ConfirmEmail", "Account", // new { createPatient.Id, token = token }, Request.Scheme); //logger.Log(LogLevel.Warning, confirmationLink); } var result = await userManager.AddToRoleAsync(user, roleName); if (!result.Succeeded) { // TODO: handle } return(Redirect("AllPatients")); }
public AddPatientView(PatientListViewModel patientListViewModel, PatientService patientService, DiagnosisService diagnosisService, PersonService personService, EmployeeService employeeService, WardService wardService, BedService bedService, PhysicianService physicianService, VitalRecordService vitalRecordService, ConditionService conditionService) { _toAddPatient = new AddPatientViewModel(patientListViewModel, patientService, personService, diagnosisService, physicianService, employeeService, wardService, bedService, vitalRecordService, conditionService); DataContext = _toAddPatient; InitializeComponent(); InsuranceCheckBox.IsChecked = true; }
public ActionResult AddPatient() { using (var db = new ApplicationDbContext()) { IEnumerable <string> facilities = from fsc in db.Facilities.ToList() where fsc.IsActive select fsc.Name; var list = new SelectList(facilities.ToList()); ViewBag.Facil = list; //---------------------ADD VISIT---------------------------------- IEnumerable <string> provider = from prov in db.Providers.ToList() where prov.User.IsActive select prov.User.UserName; var model = new AddPatientViewModel(); model.VisitDate = DateTime.Now; var listProv = new SelectList(provider.ToList()); ViewBag.Prov = listProv; //---------------------------------------------------------------- //PARAMETERS OF SEARCH------------------------------- ViewBag.first = TempData["searchFirst"] as string; ViewBag.last = TempData["searchLast"] as string; ViewBag.Active = !string.IsNullOrEmpty(TempData["unActive"] as string) && Boolean.Parse(TempData["unActive"].ToString()); ViewBag.FacilityArea = TempData["Facilit"] as string; //--------------------------------------------------- return(View()); } }
private void AddPatientPage_Loaded(object sender, RoutedEventArgs e) { MyVM = new AddPatientViewModel(); MyVM.MyCommand = new Command(x => { MessageBox.Show(MyVM.FirstName); }, y => { return(true); }); DataContext = MyVM; MyVM.MyCommand.Execute(null); }
// GET: Patients/Create public IActionResult Create() { var model = new AddPatientViewModel { Doctors = GetComboDoctors() }; return(this.View(model)); }
public ActionResult Add() { var viewModel = new AddPatientViewModel { AllPatients = GetAllPatients() }; return(View(viewModel)); }
public ActionResult AddPatient() { var model = new AddPatientViewModel { PolishCountryId = 178, Countries = _languagesRepository.GetCountriesList() }; return(View(model)); }
public ActionResult AddPatient(AddPatientViewModel patientRequest) { if (ModelState.IsValid) { var patient = _mapper.Map <AddPatientViewModel, Patient>(patientRequest); var created = _patientRepository.Create(patient); if (created) { return(RedirectToAction("Index")); } } return(View(patientRequest)); }
public IActionResult AddPatient(AddPatientViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var succeeded = _loginClient.Signup(model.Email, Password.Hash(model.Password), model.FirstName, model.LastName, model.Address, model.PhoneNumber, model.Background); if (!succeeded) { return(this.InternalServerError()); } return(RedirectToAction("Index")); }
public ViewModelLocator() { if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { PatientViewModel = new DesignPatientViewModel(); AddPatientViewModel = new DesignAddPatientViewModel(); SinglePatientViewModel = new DesignSinglePatientViewModel(); } else { PatientViewModel = new PatientViewModel.PatientViewModel(); AddPatientViewModel = new AddPatientViewModel(); SinglePatientViewModel = new SinglePatientViewModel(); OverDuePatientsViewModel = new OverDuePatientsViewModel(); } }
public async Task <Patient> Add(Therapist therapist, AddPatientViewModel viewModel) { if (viewModel is null) { throw new ArgumentNullException(nameof(viewModel)); } if (viewModel.Nhc is null && viewModel.Zip is null) { throw new ArgumentException("Nhc or zip must be not null"); } if (viewModel.Name is null) { throw new ArgumentException("Name must not be null"); } if (await _context.Patients.Where(u => u.Nhc == viewModel.Nhc).AnyAsync()) { throw new ArgumentException("This patient already exists in the db"); } var patient = new Patient { Therapist = therapist, Nhc = viewModel.Nhc, Zip = viewModel.Zip, Token = await _tokenService.GenerateToken(), FullName = viewModel.Name }; await _context.Patients.AddAsync(patient); await _context.SaveChangesAsync(); return(patient); }
public async Task <IActionResult> Create(AddPatientViewModel view) { if (ModelState.IsValid) { var user = await AddUser(view); if (user == null) { ModelState.AddModelError(string.Empty, "This email is already used."); return(View(view)); } var patient = new Patient { User = user, Doctor = await _dataContext.Doctors.FindAsync(view.DoctorId) }; _dataContext.Patients.Add(patient); await _dataContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(view)); }
public AddPatientView() { InitializeComponent(); BindingContext = new AddPatientViewModel(); ViewModel.Navigation = Navigation; }
public AddPatietnView(MainViewModel mainVM) { InitializeComponent(); DataContext = new AddPatientViewModel(mainVM); }
//GET public ActionResult AddPatient() { AddPatientViewModel apvm = new AddPatientViewModel(); return(View(apvm)); }
public AddPatients() { InitializeComponent(); BindingContext = new AddPatientViewModel(); }
public ActionResult AddPatient(AddPatientViewModel model, String location, String providerName) { using (var db = new ApplicationDbContext()) { if (ModelState.IsValid) { IEnumerable <int> selectId = from f in db.Facilities.ToList() where f.Name == location select f.Id; if (model.MiddleName == null) { model.MiddleName = " "; } Patient firstOrDefaultPatient = db.Patients.FirstOrDefault( u => u.FirstName == model.FirstName && u.LastName == model.LastName && u.MiddleName == model.MiddleName && u.DateOfBirth == model.DateOfBirth); if (firstOrDefaultPatient != null) { firstOrDefaultPatient.IsActive = true; } else { foreach (int id in selectId) { if (model.AdmissionDate != null && model.VisitDate != null) { db.Patients.Add(new Patient { LocationId = id, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, DateOfBirth = model.DateOfBirth, AdmissionDate = model.AdmissionDate, DischargeDate = null, EligibileDate = Convert.ToDateTime(model.VisitDate).AddDays(1), DeadlineDate = Convert.ToDateTime(model.VisitDate).AddDays(20), IsActive = true }); db.SaveChanges(); //------------------------------------------------------------------------- model.ProviderId = providerName; IEnumerable <string> selectedIds = from p in db.Providers.ToList() where p.User.UserName == model.ProviderId select p.ProviderId; int idPat = db.Patients.First( u => u.FirstName == model.FirstName && u.LastName == model.LastName && u.DateOfBirth == model.DateOfBirth).PatientId; foreach (string iD in selectedIds) { db.Visits.Add(new Visit { PatientId = idPat, VisitType = model.VisitType, VisitDate = model.VisitDate == null ? DateTime.Now : Convert.ToDateTime(model.VisitDate), ProviderId = iD, IsNoteComplete = false }); } //------------------------------------------------------------------------- } if (model.AdmissionDate == null && model.VisitDate != null) { db.Patients.Add(new Patient { LocationId = id, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, DateOfBirth = model.DateOfBirth, AdmissionDate = model.AdmissionDate, DischargeDate = null, EligibileDate = Convert.ToDateTime(model.VisitDate).AddDays(1), DeadlineDate = Convert.ToDateTime(model.VisitDate).AddDays(20), IsActive = true }); db.SaveChanges(); //------------------------------------------------------------------------- model.ProviderId = providerName; IEnumerable <string> selectedIds = from p in db.Providers.ToList() where p.User.UserName == model.ProviderId select p.ProviderId; int idPat = db.Patients.First( u => u.FirstName == model.FirstName && u.LastName == model.LastName && u.DateOfBirth == model.DateOfBirth).PatientId; foreach (string iD in selectedIds) { db.Visits.Add(new Visit { PatientId = idPat, VisitType = model.VisitType, VisitDate = model.VisitDate == null ? DateTime.Now : Convert.ToDateTime(model.VisitDate), ProviderId = iD, IsNoteComplete = false }); } } if (model.AdmissionDate != null && model.VisitDate == null) { db.Patients.Add(new Patient { LocationId = id, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, DateOfBirth = model.DateOfBirth, AdmissionDate = model.AdmissionDate, DischargeDate = null, EligibileDate = Convert.ToDateTime(model.AdmissionDate).AddDays(1), DeadlineDate = Convert.ToDateTime(model.AdmissionDate).AddDays(20), IsActive = true }); } if (model.AdmissionDate == null && model.VisitDate == null) { db.Patients.Add(new Patient { LocationId = id, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, DateOfBirth = model.DateOfBirth, AdmissionDate = model.AdmissionDate, DischargeDate = null, EligibileDate = null, DeadlineDate = null, IsActive = true }); } } } db.SaveChanges(); IEnumerable <string> facilities = from fsc in db.Facilities.ToList() where fsc.IsActive select fsc.Name; var list = new SelectList(facilities); ViewBag.Facil = list; //---------------------ADD VISIT---------------------------------- IEnumerable <string> provider = from prov in db.Providers.ToList() where prov.User.IsActive select prov.User.UserName; var listProv = new SelectList(provider.ToList()); ViewBag.Prov = listProv; //---------------------------------------------------------------- return(RedirectToAction("Patients", "Patient")); } else { IEnumerable <string> facilities = from fsc in db.Facilities.ToList() where fsc.IsActive select fsc.Name; var list = new SelectList(facilities.ToList()); ViewBag.Facil = list; //---------------------ADD VISIT---------------------------------- IEnumerable <string> provider = from prov in db.Providers.ToList() where prov.User.IsActive select prov.User.UserName; var listProv = new SelectList(provider.ToList()); ViewBag.Prov = listProv; //---------------------------------------------------------------- return(View(model)); } } }
public AddPatientView() { InitializeComponent(); DataContext = new AddPatientViewModel(this); }