public ActionResult <ServiceResponse> AddPatient(Patient pdata) { try { _logger.LogInformation($"Invoking endpoint: {this.HttpContext.Request.GetDisplayUrl()}"); _logger.LogDebug($"Adding patient data - {JsonConvert.SerializeObject(pdata)}"); var patient = _patientService.AddPatient(pdata); if (patient == null) { return(NotFound()); } _logger.LogInformation($"Patient data added successfully - {pdata}"); return(new ServiceResponse { Status = "true", Message = string.Empty, Result = patient }); } catch (Exception ex) { _logger.LogError($"Failed to update patient data - {ex.StackTrace}"); return(new ServiceResponse { Status = "true", Message = ex.Message, Result = "Failed to update patient data" }); } }
public async Task AddPatientTest() { var patient = new Patient { FirstName = "Dog", LastName = "Diggy", DateOfBirth = new DateTime(1960, 4, 12), StreetAddress = "66 Cotton St", Suburb = "aaaaa", PostCode = 1234, StateId = 4, Email = "*****@*****.**", Phone = "11111", Gender = "Male", EmergencyContactName = "tttt", EmergencyContactPhone = "22222", CreatedOn = DateTime.UtcNow, CreatedBy = "Test" }; var result = await _patientService.AddPatient(patient); Assert.IsNotNull(result); Assert.AreEqual(result.FirstName, patient.FirstName); // Cleanup, delete created user await _patientService.DeletePatient(patient.Id); }
public ServiceResponse <Core.Domain.Patient> AddPatient(Core.Domain.Patient patient, IFormFile file) { var response = new ServiceResponse <Core.Domain.Patient>(); try { patient = _patientService.AddPatient(patient); if (patient.Id > 0 && file != null && file.Length > 0) { patient.ImagePath = patient.Id + Path.GetExtension(file.FileName); _storage.StoreFile(patient.ImagePath, _mSTConfig.AzureBlobProfile, file.OpenReadStream()); _patientService.UpdatePatient(patient); } if (!string.IsNullOrEmpty(patient.ImagePath)) { patient.ImagePath = _mSTConfig.AzureBlobEndPoint + _mSTConfig.AzureBlobProfile + "/" + patient.ImagePath; } response.Model = patient; response.Success = true; } catch (Exception ex) { response.Success = false; response.Message = GetErrorMessageDetail(ex); } return(response); }
public async Task <IActionResult> AddPatient([FromBody] PatientViewModel formdata) { try { if (formdata == null) { return(BadRequest(new JsonResult(new { message = "object sent from client is null." }))); } else if (!ModelState.IsValid) { return(BadRequest("Invalid model object sent from client.")); } var patient = _mapper.Map <PatientDto>(formdata); var patientData = await _patientService.AddPatient(patient); if (patientData.Item1 == Guid.Empty) { return(NotFound()); } patient.Id = patientData.Item1; patient.CreatedBy = patientData.Item2; var addedPatient = _mapper.Map <PatientViewModel>(patient); return(CreatedAtAction(nameof(GetPatient), new { id = patientData.Item1 }, addedPatient)); } catch (Exception e) { return(StatusCode(500, $"Something went wrong inside add patient action: {e.Message}")); } }
public async Task <IActionResult> Post([FromBody] PatientDto patient) { await _patientService.AddPatient(patient.Email, patient.Password, patient.Pesel, patient.FirstName, patient.SecondName, patient.PhoneNumber, patient.PostCode, patient.City, patient.Street, patient.HouseNumber); return(Created("/patients", null)); }
public IActionResult AddPatient([FromBody] PatientDto patientDto) { if (ModelState.IsValid) { _patientService.AddPatient(patientDto); return(StatusCode(StatusCodes.Status201Created)); } return(BadRequest()); }
public JsonResult AddPatient(Patient patient) { var result = _patientService.AddPatient(patient); return(Json(new { sucess = result })); }
public IActionResult AddPatient([FromBody] SavePatientModel model) { if (!ModelState.IsValid) { throw new Exception(ModelState.GetErrorsMessage()); } var result = _patientService.AddPatient(model); return(Json(new { success = result })); }
public async Task <IActionResult> Add([FromBody] JObject jObj) { var result = await _patientService.AddPatient(jObj.ToAddPatientCommand(), CancellationToken.None); return(new ContentResult { StatusCode = (int)HttpStatusCode.Created, Content = JsonConvert.SerializeObject(new { id = result }), ContentType = "application/json" }); }
public IActionResult Add([FromBody] PatientInfo patient) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } _service.AddPatient(patient); return(Created("PatientInfo", patient)); }
public IActionResult AddPatient([FromBody] PatientViewModel model) { if (ModelState.IsValid) { var patient = Mapper.Map <PatientViewModel, Patient>(model); patient.CreatedDateUtc = System.DateTime.UtcNow; patient.LastModifiedDateUtc = System.DateTime.UtcNow; patient.LastModifiedBy = 1; _patientService.AddPatient(patient); } return(new HttpStatusCodeResult(200)); }
public async Task <ActionResult <String> > AddPatient(Patient_dto Patient) { try { var Id = await _pateintService.AddPatient(Patient); return(Ok(Id)); } catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(500)); } }
public IActionResult Post([FromBody] Patient patient) { if (!ModelState.IsValid) { return(BadRequest()); } if (_patientService.CheckPatientExists(patient)) { return(StatusCode(409, $"User '{patient.Name}' already exists.")); } return(Ok(_patientService.AddPatient(patient))); }
public async Task <IActionResult> AddPatient(PatientRequest patientRequest) { var patientExists = await _patientService.CheckIfAlreadyPresent(patientRequest); var patientUri = new Uri($"v1/patients", UriKind.Relative); if (patientExists != null) { return(Conflict(patientExists)); } var addPatientTask = _patientService.AddPatient(patientRequest); var patient = await addPatientTask; return(Created(patientUri, patient)); }
public async Task <IActionResult> Post([FromBody] Patient patient) { try { return(Ok(await _patientService.AddPatient(patient))); } catch (CouchDbException e) { return(BadRequest()); } catch (Exception e) { return(BadRequest()); } }
public ActionResult Registration(PatientViewModel patient) { try { PatientDTO patientDTO = new PatientDTO { Name = patient.Name, Surname = patient.Surname, Patronymic = patient.Patronymic, YearOfBirth = patient.YearOfBirth, Address = patient.Address, Email = patient.Email, Login = patient.Login, Password = patient.Password, ConfirmPassword = patient.ConfirmPassword }; UserDTO userDTO = new UserDTO { Email = patient.Email, Login = patient.Login, Password = patient.Password }; patientService.ValidatePatient(patientDTO); userService.ValidateUser(userDTO); patientService.AddPatient(patientDTO); RoleDTO roleDTO = roleService.GetRole("Пациент"); userDTO.RoleId = roleDTO.Id; userService.AddUser(userDTO); Session["Login"] = userDTO.Login; Session["Status"] = "Пациент"; return(Redirect("/")); } catch (ValidationException ex) { if (ex.Message.Contains("|")) { string[] Messages = ex.Message.Split('|'); string[] Properties = ex.Property.Split('|'); for (int i = 0; i < Messages.Length; i++) { ModelState.AddModelError(Properties[i], Messages[i]); } } else { ModelState.AddModelError(ex.Property, ex.Message); } } List <int> years = new List <int>(); for (int i = DateTime.Now.Year; i >= 1900; i--) { years.Add(i); } ViewBag.Years = new SelectList(years); return(View(patient)); }
public IActionResult AddPatient(AddPatientRequest request) { try { _patientService.AddPatient(request); return(Ok()); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public async Task <ActionResult <Patient> > PostPatient(Patient patient) { try { await _service.AddPatient(patient); } catch (PatientIdAlreadyExistException e) { return(Conflict(e)); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetPatient", new { id = patient.PatientId }, patient)); }
public void AddNewPatientText_AddsNewPatientToCollection() { // Arrange PatientInfo newPatient = new PatientInfo { Id = 11, FirstName = "Klavdia", LastName = "Popkina", BirthDate = new System.DateTime(1969, 1, 12), Gender = 2 }; // Act _service.AddPatient(newPatient); // Assert int actualCount = _service.GetPatients().Count(); int expectedCount = mockPatients.Count; bool isNewPatientAdded = _service.GetPatientById(11) != null; Assert.AreEqual(expectedCount, actualCount); Assert.AreEqual(true, isNewPatientAdded); }
public IActionResult Create([FromBody] PatientInputModel inputModel) { if (inputModel == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(UnprocessableEntity(ModelState)); } var model = ToDomainModel(inputModel); patientService.AddPatient(model); var outputModel = ToOutputModel(model); return(Created($"patients/{model.Id}", outputModel)); }
public IActionResult Create(Patient pt) { try { if (ModelState.IsValid) { patientService.AddPatient(pt); return(RedirectToAction("Index")); } else { ViewData["Msg"] = "Fail"; } } catch (Exception ex) { ViewData["Msg"] = ex.Message; } return(View()); }
public void Create(PatientModel p) { Patient pm = new Patient(); pm.Id = p.Id; pm.Nom = p.Nom; pm.Prenom = p.Prenom; pm.Date_cre = p.Date_cre; pm.CIN = p.CIN; pm.Sexe = p.Sexe; pm.Telephone = p.Telephone; pm.Adresse = p.Adresse; pm.Matricule_CNAM = p.Matricule_CNAM; pm.Date_nais = p.Date_nais; pm.Nom_fiche = p.Nom_fiche; pm.Profession = p.Profession; pm.Comtab = p.Comtab; pm.Rendez = p.Rendez; patientService.AddPatient(pm); }
public async Task <IHttpActionResult> AddApointment([FromBody] NewPatient patient) { try { var successAdded = await _patientService.AddPatient(patient); if (successAdded) { return(Ok()); } else { return(NotFound()); } } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, "Unexpected error")); } }
public string CreatePatient([Bind(Exclude = "PatientId")] PatientVM patient) { string msg; try { if (ModelState.IsValid) { patientService.AddPatient(MapperUtilVM.MapToPatientDTO(patient)); msg = "Пациент добавлен успешно"; } else { msg = "Пациент не был добавлен. Ошибка валидации модели"; } } catch (Exception ex) { msg = "Возникла ошибка: " + ex.Message; } return(msg); }
public async Task <Patient> AddPatient(Patient model) { var result = await _patientService.AddPatient(model); return(result); }
public async Task <IActionResult> RegisterPatient(PatientDTO patientDTO) { await _patientService.AddPatient(patientDTO); return(Ok(new { StatusCode = ReturnStatusCode.Ok })); }
public async Task <bool> SubmitPatientData(PatientViewModel PatientData) { return(await patientService.AddPatient(PatientData)); }