public ActionResult EditPatient(string id, string type) { //PODŁĄCZENIE KLIENTA var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; ViewBag.ID = id; if (type == "Patient") { //WYSZUKANIE ZASOBU Patient patient = client.Read <Patient>("Patient/" + id); EditPatient myPatient = new EditPatient(); //PRZEKAZANIE DANYCH myPatient.Name = patient.Name[0].Given.FirstOrDefault(); myPatient.Surname = patient.Name[0].Family; myPatient.Address = patient.Address[0].Text; myPatient.ID = patient.Id; return(View(myPatient)); } ViewBag.Message = "Some Error until Redirect"; return(View()); }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { EditPatient editpatient = new EditPatient(/*0*/); MainWindow.AppWindow.ContentC.Content = editpatient; //((MainWindow)Application.Current.MainWindow).ContentC.Content = editpatient; }
public async Task <IActionResult> Edit(long id) { Patient patient = null; if (User.IsInRole("Doctor") && !_context.Doctor_Patients.Any(r => r.Doctor.User.Id == _userManager.GetUserId(User) && r.Patient.Id == id)) { return(View("~/Areas/Identity/Pages/Account/AccessDenied.cshtml")); } if (User.IsInRole("Patient")) { patient = _context.Patients.Include(p => p.User).Include(p => p.InsuranceCompany).Where(p => p.User.Id == _userManager.GetUserId(User)).Single(); } else { patient = _context.Patients.Include(p => p.User).Include(p => p.InsuranceCompany).Single(p => p.Id == id); } if (patient == null) { return(NotFound()); } ViewData["Companies"] = getCompanies(patient); long company = 0; if (patient.InsuranceCompany != null) { company = patient.InsuranceCompany.Id; } EditPatient model = new EditPatient { Id = patient.Id, FirstName = patient.FirstName, MiddleName = patient.MiddleName, LastName = patient.LastName, Gender = patient.Gender, Image = patient.Image, Mobile = patient.Mobile, BloodType = patient.BloodType, Birthdate = patient.Birthdate, DisplayName = patient.DisplayName, Address = patient.Address, Username = patient.User.UserName, Email = patient.User.Email, Phone = patient.User.PhoneNumber, SelectedInsuranceCompanyId = company }; return(View(model)); }
private void EditSelectedPatient_Button_Click(object sender, EventArgs e) { EditPatient editPatient = new EditPatient(); editPatient.PopulateEditpatient_fields(this.patientController.GetPatientByID(this.selectedPatientID)); DialogResult result = editPatient.ShowDialog(); if (result == DialogResult.OK) { this.GetAppointmentData_ForSelectedPatient(this.selectedPatientID); } }
private void Edit_Button_Click(object sender, RoutedEventArgs e) { if (patientsTable.SelectedCells.Count > 0) { /*PatientStorage ps = new PatientStorage(); * List<Patient> temp = ps.GetAll(); * Patients = new ObservableCollection<Patient>(temp);*/ Patient p = (Patient)patientsTable.SelectedItem; var s = new EditPatient(p); s.Show(); } else { MessageBox.Show("Niste selektovali pacijenta!"); } }
private void buttonEdit_Click(object sender, RoutedEventArgs e) { var row = (Patient)dataGridViewResult.SelectedItem; //var row = (System.Data.DataRowView)dataGridViewResult.SelectedItems[0]; //var patient = GetSelectedPatient(); if (row == null) { return; } //int patientId = patient.PatientID; EditPatient editpatient = new EditPatient(row.Id); MainWindow.AppWindow.ContentC.Content = editpatient; // App..Current.MainWindow= editpatient; }
public ActionResult EditPatient([Bind] EditPatient patient) { bool status = false; string Message = ""; //SPRAWDZENIE MODELU if (ModelState.IsValid) { //PODŁĄCZENIE KLIENTA var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; //PRZEKAZANIE DANYCH Patient original = client.Read <Patient>("Patient/" + patient.ID); HumanName name = new HumanName(); name.WithGiven(patient.Name).AndFamily(patient.Surname); original.Name.Add(name); Address address = new Address(); address.Text = patient.Address; original.Address.Add(address); //UPDATE client.Update(original); Message = "Your item successfully UPDATE"; status = true; } else { Message = "You haven't got right model"; } ViewBag.ID = patient.ID; ViewBag.Status = status; ViewBag.Message = Message; return(View(patient)); }
private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "ItemDoctors": { Doctors doctors = new Doctors(); ContentC.Content = doctors; break; } case "ItemPatients": { if (Membership.CurrentUser.RoleID == 3) { EditPatient editPatient = new EditPatient(Membership.CurrentUser.Patient.Id); ContentC.Content = editPatient; } else { Patients patients = new Patients(); ContentC.Content = patients; } break; } case "ItemVisits": { Visits visits = new Visits(); ContentC.Content = visits; break; } case "ItemAddDoctor": { EditDoctor newForm = new EditDoctor(); newForm.ShowDialog(); break; } case "ItemAddAdmin": { EditUser newForm = new EditUser(0); newForm.ShowDialog(); break; } case "ItemAddPatient": { EditPatient editpatient = new EditPatient(/*0*/); MainWindow.AppWindow.ContentC.Content = editpatient; break; } case "Statistics": { Statistics item = new Statistics(); MainWindow.AppWindow.ContentC.Content = item; break; } default: break; } }
public async Task <IActionResult> Edit(long id, EditPatient model, IFormFile file) { string returnAction = "Search"; if (id != model.Id) { return(NotFound()); } if (User.IsInRole("Doctor") && !_context.Doctor_Patients.Any(r => r.Doctor.User.Id == _userManager.GetUserId(User) && r.Patient.Id == id)) { return(View("~/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs")); } Patient patient = null; if (User.IsInRole("Patient")) { patient = _context.Patients.Include(p => p.User).Include(p => p.InsuranceCompany).Where(p => p.User.Id == _userManager.GetUserId(User)).Single(); returnAction = "Profile"; } else { patient = _context.Patients.Include(p => p.InsuranceCompany).Include(p => p.User).Single(p => p.Id == model.Id); } if (patient == null) { return(NotFound()); } if (ModelState.IsValid) { IdentityUser user = patient.User; var username = await _userManager.GetUserNameAsync(user); if (model.Username != username) { if (_userManager.Users.Any(u => u.UserName == model.Username)) { ModelState.AddModelError(String.Empty, "User name already taken"); ViewData["Companies"] = getCompanies(patient); return(View(model)); } var setUserNameResult = await _userManager.SetUserNameAsync(user, model.Username); if (!setUserNameResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting username for user with ID '{userId}'."); } } try { if (file != null) { var filePath = Path.GetTempFileName(); using (FileStream filestream = System.IO.File.Create(_environment.WebRootPath + "\\images\\" + file.FileName)) { model.Image = file.FileName; file.CopyTo(filestream); filestream.Flush(); } } InsuranceCompany insurance = _context.InsuranceCompanies.Find(model.SelectedInsuranceCompanyId); patient.FirstName = model.FirstName; patient.MiddleName = model.MiddleName; patient.LastName = model.LastName; patient.Gender = model.Gender; patient.Image = model.Image; patient.Mobile = model.Mobile; patient.BloodType = model.BloodType; patient.Birthdate = model.Birthdate; patient.DisplayName = model.DisplayName; patient.Address = model.Address; patient.InsuranceCompany = insurance; var email = await _userManager.GetEmailAsync(user); if (model.Email != email) { var setEmailResult = await _userManager.SetEmailAsync(user, model.Email); if (!setEmailResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting email for user with ID '{userId}'."); } } var phoneNumber = await _userManager.GetPhoneNumberAsync(user); if (model.Phone != phoneNumber) { var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, model.Phone); if (!setPhoneResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting phone number for user with ID '{userId}'."); } } patient.User = user; _context.Update(patient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(patient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(returnAction)); } ViewData["Companies"] = getCompanies(patient); return(View(model)); }