public void CreateAppointmentSuccessfully() { var patient = new PatientDto { Name = "Felipe Cristo de Oliveira", BirthDate = new DateTime(1991, 2, 3) }; patient = _patientService.Create(patient); var appointment = new AppointmentDto { PatientId = patient.Id, StartedAt = new DateTime(2020, 04, 01, 15, 30, 0), FinishedAt = new DateTime(2020, 04, 01, 16, 0, 0), Comments = "Comment test" }; var appointmentCreated = _service.Create(appointment); Assert.NotEqual(0, appointmentCreated.Id); Assert.Equal(appointment.PatientId, appointmentCreated.PatientId); Assert.Equal(appointment.StartedAt, appointmentCreated.StartedAt); Assert.Equal(appointment.FinishedAt, appointmentCreated.FinishedAt); Assert.Equal(appointment.Comments, appointmentCreated.Comments); }
public void Create() { //Arrange var registrant = _dataContext.UserAccounts.First(); var viewModel = new PatientViewModel { Nhc = "123", Nuhsa = "123456", Name = "Test", Surnames = "Testing", Sex = PatientSex.Male, BirthDate = DateTime.Now, BirthType = BirthType.Eutocic, Ph = 8, Apgar = 10, Weight = 5000, CprType = null }; //Act var patientId = _patientService.Create(viewModel, registrant.UserName, registrant.Id); var patient = _patientService.FindById(patientId); //Assert Assert.That(patientId, Is.Not.Zero); Assert.That(patient, Is.Not.Null); Assert.That(patient.PatientStatus, Is.EqualTo(PatientStatus.Normal)); Assert.That(patient.RegistrantName, Is.EqualTo(registrant.UserName)); Assert.That(patient.RegistrantId, Is.EqualTo(registrant.Id)); }
public IActionResult CreateDetail([FromBody] UserDetailMediCoreModel model) { AssignModelState(); var response = _userDetailService.Create(model); if (response.Success) { // by default user is patient var patientResponse = _patientService.Create(new PatientModel { PatientName = String.Format("{0} {1}", model.FirstName, model.LastName), DateOfBirth = model.Patient.DateOfBirth, PatientStatus = PatientStatus.Active, Gender = model.Patient.Gender, RelationshipStatus = RelationshipStatus.YourSelf, AssociatedUserId = response.Item.UserId }); if (patientResponse.Success) { // Update User Detail var detail = response.Item; detail.PatientId = patientResponse.Item.Id; var userResponse = _userDetailService.Edit(response.Item); if (userResponse.Success) { return(Ok(userResponse.Item)); } } } return(BadRequest(response.Message)); }
public IActionResult CreatePatient([FromBody] CreatePatientViewModel createPatientViewModel) { var patientDTO = PatientMapper.CreatePatientVMToDTO(createPatientViewModel); _service.Create(patientDTO); return(Ok(ModelState)); }
public ActionResult CreatePatient(PatientViewModel patient) { if (ModelState.IsValid) { _patientService.Create(patient); return(Json(new { success = true })); } return(Json(new { success = false, error = ModelState.Values.FirstOrDefault(v => v.Errors?.Count > 0).Errors.FirstOrDefault()?.ErrorMessage })); }
public async Task <IActionResult> Post(PatientInputModel model) { if (model == null) { return(BadRequest()); } var createdEntity = await _patientService.Create(model); return(CreatedAtAction("Get", new { createdEntity.Id }, createdEntity)); }
public async Task <Guid> CreatePatientAsync(PatientDto patient) { using (var uow = UnitOfWorkProvider.Create()) { if ((await patientService.GetPatientByUsernameAsync(patient.Username)) != null) { throw new ArgumentException(); } var patientId = patientService.Create(patient); await uow.Commit(); return(patientId); } }
public ActionResult Post([FromBody] PatientViewModel userVM) { var user = _mapper.Map <Patient>(userVM); try { _userService.Create(user, userVM.Password); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Post([FromBody] PatientModel param) { AssignModelState(); var res = _patientService.Create(param); if (res.Success) { return(Ok(res.Item)); } else { return(BadRequest(res.Message)); } }
//public DataSourceResult Get(HttpRequestMessage requestMessage) //{ // DataSourceRequest request = JsonConvert.DeserializeObject<DataSourceRequest>( // // The request is in the format GET api/products?{take:10,skip:0} and ParseQueryString treats it as a key without value // requestMessage.RequestUri.ParseQueryString().GetKey(0) // ); // return db.Products // //Entity Framework can page only sorted data // .OrderBy(product => product.ProductID) // .Select(product => new // { // // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding. // product.ProductID, // product.ProductName, // product.Discontinued, // product.QuantityPerUnit, // product.ReorderLevel, // product.UnitPrice, // product.UnitsInStock, // product.UnitsOnOrder // }) // .ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter); //} //public HttpResponseMessage Update(int id, PatientData patientData) //{ // if (ModelState.IsValid && id == patientData.Id) // { // try // { // _patientService.Update(); // } // catch (DbUpdateConcurrencyException) // { // return Request.CreateResponse(HttpStatusCode.NotFound); // } // return Request.CreateResponse(HttpStatusCode.OK); // } // else // { // return Request.CreateResponse(HttpStatusCode.BadRequest); // } //} public HttpResponseMessage Post(PatientData patientData) { if (ModelState.IsValid) { _patientService.Create(patientData); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, patientData); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = patientData.Id })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public JsonResult AddOrEdit(Patient Model) { if (ModelState.IsValid) { if (Model.Id == 0) { patientService.Create(Model); } else { patientService.Update(Model); } } return(Json(1)); }
public async Task <IActionResult> Create(PatientCreateInputModel patientCreateInputModel) { if (!ModelState.IsValid) { await GetAllDepartments(); return(View(patientCreateInputModel)); } PatientServiceModel patientServiceModel = AutoMapper.Mapper.Map <PatientServiceModel>(patientCreateInputModel); await patientService.Create(patientCreateInputModel.Password, patientServiceModel); return(Redirect("/Patient/All")); }
public ActionResult Create(PatientViewModel patient) { if (!ModelState.IsValid) { return(View(patient)); } //Get current user credentials to store as creator of the patient var registrant = User.Identity.GetUserName(); var registrantId = User.Identity.GetUserId <int>(); var newPatient = _patientService.Create(patient, registrant, registrantId); _patientService.Log(OperationType.PatientCreate, registrantId, patientId: newPatient); return(RedirectToAction("List")); }
public async Task <IActionResult> Post([FromBody] CreatePatientDto patient) { if (patient == null) { return(await ResponseNullOrEmpty()); } var listError = ValidPropertiesObject.ObjIsValid(patient); if (listError.Count > 0) { return(await ResponseNullOrEmpty(listError)); } var result = _service.Create(patient); return(await Response(result, _service.Validate())); }
public Task <ApiResponse> Handle(CreatePatientCommand request, CancellationToken cancellationToken) { Gender?gender = null; if (!string.IsNullOrEmpty(request.Gender)) { gender = (Gender)Enum.Parse(typeof(Gender), request.Gender, true); } _patientService.Create( new Domain.Entities.Resources.Patient { Name = request.Name, DateOfBirth = request.DateOfBirth, Gender = gender }); return(Task.FromResult(new ApiResponse())); }
public async Task <ApiResponse> Create([FromBody] PatientCreateRequest request) { try { var FhirResult = _fhirPatientRequestService.AddPatientAsync(request); request.ExternalId = FhirResult.Result; var result = await _objControllerHelper.Create(request); if (result.Status == PatientCreateStatus.Success) { return(new ApiResponse(request.ExternalId)); } return(new ApiResponse(400, result.Error)); } catch (Exception ex) { throw new ApiException(ex); } }
public async Task <ActionResult> Create(CreatePatientViewModel patientViewModel) { if (!ModelState.IsValid) { patientViewModel.Doctors = GetDoctorListForPatientsViewModel(_doctorService.GetDoctors()); return(View(patientViewModel)); } var patient = _mapper.Map <CreatePatientViewModel, Patient>(patientViewModel); if (!_patientService.CheckUniqueness(patient)) { ModelState.AddModelError("", "User with same UserName or Email exist!"); patientViewModel.Doctors = GetDoctorListForPatientsViewModel(_doctorService.GetDoctors()); return(View(patientViewModel)); } await _patientService.Create(patient); _loggerService.Info($"{User.Identity.Name} added {patient.FirstName} {patient.LastName}"); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(PatientCreateFromFirstLoginInputModel patientCreateFromFirstLoginInputModel) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var hospitalMSUser = (await userService.GetById(userId)).To <HospitalMSUserViewModel>(); if (!ModelState.IsValid) { return(View(patientCreateFromFirstLoginInputModel)); } PatientServiceModel patientServiceModel = AutoMapper.Mapper.Map <PatientServiceModel>(patientCreateFromFirstLoginInputModel); patientServiceModel.Email = hospitalMSUser.Email; patientServiceModel.HospitalMSUserId = hospitalMSUser.Id; await patientService.Create(patientServiceModel); return(Redirect("Index")); }
private void btnRegis_Click(object sender, EventArgs e) { string gender = ""; if (rbMale.Checked) { gender = "E"; } else if (rbFemale.Checked) { gender = "K"; } else { gender = ""; } try { Patient patient = new Patient() { Name = txtName.Text, Surname = txtSurname.Text, IdentificationNumber = txtId.Text, Phone = txtPhone.Text, DateOfBirth = DateTime.Parse(txtBday.Text), Gender = gender, DateOfRegistration = DateTime.Now.Date, CityId = cmbCity.SelectedIndex + 1, Password = "******" + txtId.Text.Substring(0, 6) // "mhrs402734" }; patientService.Create(patient); LoginPage login = new LoginPage(); MaterialMessageBox.Show(string.Format("{0} {1} şifreniz {2} \n Değiştirmek için Hesap Bilgilerinize giriniz...", patient.Name, patient.Surname, patient.Password), "İlk Giriş", MessageBoxButtons.YesNo); login.sign(patient.IdentificationNumber, patient.Password); } catch (Exception err) { Console.WriteLine(err.Message); } }
public async Task <IActionResult> Create(PatientDataModel request) { if (ModelState.IsValid is false) { request.HealthInsurances = await _healthInsuranceService.GetAll(); return(PartialView("_CreatePatient", request)); } await _patientService.Create(request); if (ValidOperation() is false) { request.HealthInsurances = await _healthInsuranceService.GetAll(); return(PartialView("_CreatePatient", request)); } var url = Url.Action("Index", "Patient"); return(Json(new { success = true, url, messageText = "Paciente Cadastrado com Sucesso!" })); }
public ActionResult CreatePatient(PatientViewModel patient) { _patientService.Create(patient); return(RedirectToAction("Patients")); }
public PatientDto Create([FromBody] PatientDto data) { return(_service.Create(data)); }
public async Task <Guid> Create(PatientInfo infoModel) { return(await _patientService.Create(infoModel)); }
public async Task <ActionResult> Post([FromBody] CreatePatientRequest request) { var response = await _patientService.Create(request); return(GetApiResponse(response)); }
public bool Post([FromBody] Patient value) { var result = _patientService.Create(value); return(result); }