public async Task <ActionResult> CreatePatient(Patient patient) { if (patient == null) { ModelState.AddModelError("Patient", "Could not create an patient, the passed in Patient cannot be null."); return(BadRequest(ApiResponse.BadRequest(ModelState))); } if (await _patientService.UserIdExistsAsync(patient.UserId)) { ModelState.AddModelError("Patient.UserId", "An patient already exists for this User Id, only one patient is allowed per User Id."); return(BadRequest(ApiResponse.BadRequest(ModelState))); } var createdPatientId = await _patientService.CreatePatientAsync(patient); patient = await _patientService.GetPatientAsync(createdPatientId); return(CreatedAtAction( nameof(GetPatientById), new { patientId = createdPatientId }, // ApiResponse.Result(patient) patient )); }
public async Task <IActionResult> Post([FromBody] PatientModel patientModel) { var result = await _patientService.CreatePatientAsync(patientModel); if (result) { return(Ok()); } else { return(UnprocessableEntity()); } }
public async Task <IActionResult> CreatePatient(PatientViewModel model) { if (ModelState.IsValid) { _logger.LogInformation($"Patient - Create Patient Post Request"); var mappedModel = _mapper.Map <PatientDTO>(model); await _patientService.CreatePatientAsync(mappedModel); return(RedirectToAction("GetPatients")); } return(View(model)); }
public void Create_And_Get_Patients() { IEnumerable <Core.Patient.Patient> patientList = _patientService.GetPatients().Result; Assert.True(patientList.Count() >= 0); Core.Patient.Patient patient = new Core.Patient.Patient(); patient.Name = "John Test Test1"; patient.PhoneNumber = "8623452673"; patient.Address = "300 N Kendall Rd"; var result = _patientService.CreatePatientAsync(patient); patientList = _patientService.GetPatientsByNameAsync(patient.Name).Result; Assert.True(patientList.Count() >= 1); }
public async Task <IActionResult> CreatePatientAsync([FromBody] PatientDto patient) { Logger.LogDebug(nameof(CreatePatientAsync)); if (ModelState.IsValid) { var newPatient = await _patientService.CreatePatientAsync(patient).ConfigureAwait(false); if (newPatient == null) { return(NotFound(new NotFoundError("The patient was not created"))); } var result = _patientToDtoConverter.Convert(newPatient); return(Ok(result)); } else { var errors = ModelStateErrors(); return(BadRequest(errors)); } }
public async Task <IActionResult> CreateAsync([FromBody] CreatePatientInput input) { AppResponse response = await _patientService.CreatePatientAsync(input); return(Ok(response)); }
public async Task <HttpResponseMessage> Create([FromBody] PatientInfo body) { return(await _patientService.CreatePatientAsync(body)); }
public PatientResultViewModel CreateNewPatient(List <PatientRequestModel> newPatients) { var result = new PatientResultViewModel(); try { var patients = new List <Patient>(); var family = new Family { Name = newPatients[0].LastName }; foreach (PatientRequestModel newPatient in newPatients) { var userContext = _userHandler.GetUserContext(); var patient = new Patient(); patient.Address = new Address() { CreatedDateUtc = DateTime.UtcNow, AddressTypeId = 1, Address1 = newPatient.Address1, Address2 = newPatient.Address2, AttentionTo = "", City = newPatient.City, CountryId = newPatient.CountryId, RegionId = newPatient.StateId, PostalCode = newPatient.PostalCode, CreatedBy = userContext.SiteUserId }; patient.Id = newPatient.PatientId; patient.FirstName = newPatient.FirstName; patient.LastName = newPatient.LastName; patient.ClinicId = userContext.ClinicId; patient.Age = 30; patient.Status = 1; patient.Title = "Mr."; patient.Gender = 1; patient.Phone = newPatient.Phone; patient.Email = newPatient.Email; patient.CreatedDateUtc = DateTime.UtcNow; patient.CreatedBy = userContext.SiteUserId; patient.Family = family; patient.PrimaryMember = true; patient.Minor = false; patient.DoctorId = userContext.DoctorId ?? 0; patients.Add(patient); } _patientService.CreatePatientAsync(patients); result = new PatientResultViewModel { Success = true, Message = "Add patient success. ", PatienId = patients.First().Id }; } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public async Task CreatePatient(Patient patient, CancellationToken cancellationToken) { patient.Id = Guid.NewGuid(); await _patientService.CreatePatientAsync(patient, cancellationToken).ConfigureAwait(false); }