public void given_new_patient_when_adding_should_return_new_id() { _repository.Add(Arg.Any <Patient>()).Returns(1, 3, 5); Assert.That(_service.AddPatient(new Patient()), Is.EqualTo(1)); Assert.That(_service.AddPatient(new Patient()), Is.EqualTo(3)); Assert.That(_service.AddPatient(new Patient()), Is.EqualTo(5)); }
public void AddPatient_ValidatesRequest() { //arrange var request = _fixture.Create <AddPatientRequest>(); //act _patientService.AddPatient(request); //assert _validator.Verify(x => x.ValidateRequest(request), Times.Once); }
public async Task AddPatientIncreasesCountOfUsers() { var newPatient = ModelFakes.PatientFake.Generate(); await _testService.AddPatient(newPatient); var allPatients = await _testService.GetAllPatients(); List <Patient> listOfPatients = (List <Patient>)allPatients; listOfPatients.Count.Should().Be(11); }
public async Task <IHttpActionResult> AddPatient(PatientModel patient) { if (patient == null) { return(BadRequest("Please provide valid inputs!")); } CommonResponse validatedResponse = await AuthService.ValidateUserAndToken(); if (!validatedResponse.IsError) { if (await PatientService.PatientExists(patient)) { return(BadRequest("Patient Already Exists")); } else { if (await PatientService.AddPatient(patient)) { return(Ok("Patient Added Successfully!")); } else { return(BadRequest("Patient Adding Failed!")); } } } else { return(Unauthorized()); } }
// Класс разбит на регионы (Пацента, Врача, Записи), так как количество полей интерфейса велико и записи выходят громоздкими // Логика всех регионов идентична, есть методы на добавление, обновление, удаление, отмену обновления, обработка выбранного элемента таблицы // Для региона с записями добавлены так же списки для выбора пациента и врача #region Patient // Добавляет пациента private void btnAddPatient_Click(object sender, EventArgs e) { lbError.Text = ""; PatientService service = new PatientService(); if (!string.IsNullOrEmpty(txtNumber.Text) && !string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtLastName.Text) && !string.IsNullOrEmpty(txtPatronomic.Text)) { Patient patient = new Patient() { FirstName = txtName.Text, LastName = txtLastName.Text, Patronimic = txtPatronomic.Text, Number = txtNumber.Text, DateBth = dateBth.Value, Id = Guid.NewGuid().ToString() }; service.AddPatient(patient); var patients = service.GetAll(); dgPatients.Rows.Clear(); foreach (var p in patients) { dgPatients.Rows.Add(p.Number, p.FirstName, p.LastName, p.Patronimic, p.DateBth, p.Id); } } else { lbError.Text = "Filed can't be empty"; } }
public async Task <IActionResult> RegisterPatient(PatientAccountWrapperModel model) { if (!ModelState.IsValid) { model.RegisterModel.TabSelected = "2"; return(View("PatientSignInUp", model)); } var result = await _accountService.RegisterPatient( model.RegisterModel.FirstName, model.RegisterModel.LastName, model.RegisterModel.EGN, model.RegisterModel.PhoneNumber, model.RegisterModel.Password); if (result.Succeeded) { var user = await _accountService.GetUserByName(model.RegisterModel.EGN); await _patientService.AddPatient(user.Id, user.PhoneNumber); return(RedirectToAction("Index", "Home")); } foreach (var err in result.Errors) { ModelState.AddModelError("", err); } model.RegisterModel.TabSelected = "2"; return(View("PatientSignInUp", model)); }
public ActionResult <Patient> Create([FromBody] Patient patient) { if (patient.Id != 0) { return(BadRequest()); } return(patientService.AddPatient(patient)); }
public static void ClientMenu() { while (true) { Console.Clear(); Console.WriteLine("--------------Client Menu--------------"); Console.WriteLine("1.Login"); Console.WriteLine("2.New Client"); Console.WriteLine("0.Back"); string optionInput = Console.ReadLine(); try { var op = Parse(optionInput); switch (op) { case 1: { Console.Clear(); Console.WriteLine("Enter your access code"); string input = Console.ReadLine(); try { var id = Parse(input); if (PatientService.GetPatient(id) != null) { LoggedClientMenu(id); } } catch (FormatException e) { Console.WriteLine(e.Message); } break; } case 2: { Console.Clear(); Console.WriteLine("Enter your name: "); string name = Console.ReadLine(); LoggedClientMenu(PatientService.AddPatient(name)); break; } } if (op == 0) { break; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
protected async Task HandleValidSubmit() { await PatientService.AddPatient(Patient); ShowDialog = false; await CloseCallback.InvokeAsync(true); StateHasChanged(); }
protected void ok_Click(object sender, EventArgs e) { //判断输入的病人名字是否有数字、字母或非法字符 String name = this.name.Text; if (publicService.isContainNumberOrSpecialCharOrEnglish(name) == true) { Response.Write("<script language=javascript>window.alert('病人姓名中含有数字或字母或非法字符!');</script>"); return; } //判断输入的职业是否有数字或非法字符 String occupation = this.job.Text; if (publicService.isContainNumberOrSpecialChar(occupation) && occupation.Equals("") == false) { Response.Write("<script language=javascript>window.alert('所填的职业中含有数字或非法字符!');</script>"); return; } Patient patient = new Patient(); patient.Id = this.patientNum.Text; patient.Name = this.name.Text; patient.Sex = this.sex.SelectedItem.ToString(); patient.Age = Convert.ToInt32(this.Age.Text); patient.Tel = this.Tel.Text; patient.Department = this.department.Text; patient.DrugAllergy = this.allergicCondition.Text; patient.MedicalHistory = this.illHistory.Text; patient.RoomNum = roomNumber.Text; patient.BedNum = bedNumber.Text; patient.PhysicanNum = physician.Text; //入院日期改为系统获得,可以将显示界面的那两个时间输入框删除了 patient.AdmissionTime = System.DateTime.Now.ToString(); patient.IDNum = idNum.Text; patient.BirthDate = birthDate.Text; patient.Nation = nation.Text; patient.Country = nationality.Text; patient.Marriage = MarriageList.Text; patient.Occupation = job.Text; patient.NativePlace = this.NativeProvinceList.SelectedItem.Text.Trim() + this.NativeCityList.SelectedItem.Text.Trim(); patient.BirthPlace = this.BirthProvince.SelectedItem.Text.Trim() + BirthCity.SelectedItem.Text.Trim(); patient.Address = livingAddress.Text; patient.WorkingPlace = workingAddress.Text; patient.WorkingTel = workingTel.Text; patient.Diagonse = diagnosis.Text; //邮编没有输入框,传了一个空字符串过去 if (PatientService.AddPatient(patient) != -1) { Response.Write("<script language=javascript>window.alert('病人入院登记成功!');</script>"); } else { Response.Write("<script language=javascript>window.alert('该病人编号已存在,请输入其他编号!');</script>"); } }
public ActionResult Register(Patient model) { if (ModelState.IsValid) { if (pth.AddPatient(model)) { ViewBag.Message = "Patient Added Successfully"; ModelState.Clear(); } return(View()); } else { return(View(model)); } }
public ActionResult <string> Post([FromBody] Patient patient) { ActionResult retval = BadRequest(patient); try { if (_patientService.AddPatient(patient)) { retval = new OkObjectResult(patient); } } catch (Exception e) { Console.Write(e); } return(retval); }
public IActionResult AddDoctorRequest([FromBody] DoctorRequestViewModel doctorRequest) { if (!ModelState.IsValid) { return(BadRequest("Can't add request")); } try { Patient patient = new Patient(); if (doctorRequest.Patient.LastName == null) { patient = patientService.GetPatientByCNP(doctorRequest.Patient.CNP); patient.Status = PatientStatus.INTERNAT; } else { Address address = Mappers.MapperPatient.ToAddressDb(doctorRequest.Patient); patient = Mappers.MapperPatient.ToPatientDb(doctorRequest.Patient); patient.Status = PatientStatus.INTERNAT; var id = Request.Cookies["UserId"]; Doctor doctor = doctorsService.GetDoctorById(id); patient.IdDoctor = doctor.Id; patientService.AddPatient(patient, address); } Request request = Mappers.MapperDoctorRequest.ToDoctorRequestDb(doctorRequest); request.IdPatient = patient.Id; request = doctorsService.AddRequest(request); doctorRequest.dateOfRequest = request.DateOfRequest; doctorRequest.id = request.Id; EmployeeRequestModelView employeeRequest = Mappers.MapperDoctorRequest.ToEmployeeRequest(request); this.broadcaster.Clients.Group("DonationCenterDoctor").SendRequest(employeeRequest); return(Ok(request)); }catch (Exception ex) { return(BadRequest("Can't add request")); } }
// POST api/values public long Post(Patient patient) { return(_service.AddPatient(patient)); }
public IActionResult Create([FromForm] string firstname, [FromForm] string surname) { patientService.AddPatient(firstname, surname); return(RedirectToAction("", "Patient")); }
public void AddPatient(Patient newPatient) { patientService.AddPatient(newPatient); }