Ejemplo n.º 1
0
        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"
                });
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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}"));
            }
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
 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
            }));
        }
Ejemplo n.º 8
0
        public IActionResult AddPatient([FromBody] SavePatientModel model)
        {
            if (!ModelState.IsValid)
            {
                throw new Exception(ModelState.GetErrorsMessage());
            }
            var result = _patientService.AddPatient(model);

            return(Json(new { success = result }));
        }
Ejemplo n.º 9
0
        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"
            });
        }
Ejemplo n.º 10
0
        public IActionResult Add([FromBody] PatientInfo patient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data"));
            }

            _service.AddPatient(patient);

            return(Created("PatientInfo", patient));
        }
Ejemplo n.º 11
0
 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));
 }
Ejemplo n.º 12
0
        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));
            }
        }
Ejemplo n.º 13
0
        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)));
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
 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());
     }
 }
Ejemplo n.º 16
0
        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));
        }
Ejemplo n.º 17
0
 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));
     }
 }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 21
0
 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);
        }
Ejemplo n.º 23
0
        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"));
            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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 }));
        }
Ejemplo n.º 27
0
 public async Task <bool> SubmitPatientData(PatientViewModel PatientData)
 {
     return(await patientService.AddPatient(PatientData));
 }