コード例 #1
0
 public ActionResult Create(PatientViewModel vm, string patientId = "")
 {
     try
     {
         _patientService.Add(Mapper.Map <Patient>(vm));
         return(JavaScript("ShowResult('Data saved successfully.','success')"));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #2
0
        public HttpResponseMessage addupFromApp(HttpRequestMessage request)
        {
            HttpContent           requestContent = Request.Content;
            string                jsonContent    = requestContent.ReadAsStringAsync().Result;
            PhieuSangLocViewModel phieuSangLocVm = JsonConvert.DeserializeObject <PhieuSangLocViewModel>(jsonContent);

            var userName = HttpContext.Current.GetOwinContext().Authentication.User.Identity.Name;
            var user     = userManager.FindByNameAsync(userName).Result;

            if (phieuSangLocVm.MaTrungTam != user.LevelCode && !phieuSangLocVm.IDPhieu.Contains(user.LevelCode))
            {
                return(request.CreateResponse(HttpStatusCode.ExpectationFailed, "Phiếu " + phieuSangLocVm.IDPhieu + "không thuộc trung tâm " + user.LevelCode));
            }

            HttpResponseMessage response = null;

            var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu);

            if (phieuDB == null)
            {
                var newPhieu = new PhieuSangLoc();
                newPhieu.UpdatePhieuSangLoc(phieuSangLocVm);

                var lvcode = user.LevelCode;
                newPhieu.IDNhanVienTaoPhieu = user.Id;
                var newPatient = new Patient();
                newPatient.UpdatePatient(phieuSangLocVm);
                newPhieu.MaBenhNhan   = lvcode[1] + lvcode[2] + Guid.NewGuid().ToString();
                newPatient.MaBenhNhan = newPhieu.MaBenhNhan;
                phieuSangLocService.Add(newPhieu);
                patientService.Add(newPatient);
                phieuSangLocService.Save();
                response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm);
            }
            else
            {
                phieuDB.UpdatePhieuSangLoc(phieuSangLocVm);
                var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan);
                patientDB.UpdatePatient(phieuSangLocVm);

                this.phieuSangLocService.Update(phieuDB);
                this.patientService.Update(patientDB);
                donViCoSoService.Save();

                response = request.CreateResponse(HttpStatusCode.OK);
            }
            return(response);
        }
        public async Task <OkObjectResult> Post([FromBody] Patient patient)
        {
            var Patient = new Patient()
            {
                Name         = patient.Name,
                Surname      = patient.Surname,
                UserId       = patient.UserId,
                Gender       = patient.Gender,
                telNumber    = patient.telNumber,
                birthdayDate = patient.birthdayDate,
                Adress       = patient.Adress,
                PESEL        = patient.PESEL
            };

            try
            {
                var result = await _patientService.Add(Patient);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public async Task <IActionResult> CreatePetient(int doctorId, PatientForCreateDto patientForCreateDto)
        {
            if (doctorId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized("Пользователь не авторизован"));
            }

            patientForCreateDto.PersonalCardNumber = patientForCreateDto.PersonalCardNumber.Trim();

            if (await _patientService.PatientIsExistAsync(patientForCreateDto.PersonalCardNumber))
            {
                return(BadRequest("В системе уже существует пациент с указым номером карточки."));
            }

            var patient = _mapper.Map <Patient>(patientForCreateDto);

            _patientService.Add(patient);

            if (await _patientService.SaveAllAsync())
            {
                return(Ok(patient));
            }

            throw new Exception("Не предвиденая ошибка в ходе добавления пациента, обратитесь к администратору.");
        }
コード例 #5
0
        public IActionResult Add(Patient patient)
        {
            if (_patientService.Add(patient) == null)
            {
                return(NotFound());
            }

            return(Ok(PatientAdapter.PatientToPatientDto(patient)));
        }
コード例 #6
0
        public async Task <IActionResult> CreatePatient(PatientDTO patientDTO)
        {
            if (ModelState.IsValid)
            {
                await _patientService.Add(patientDTO);
            }

            return(Ok($"Paciente {patientDTO.Name} cadastrado."));
        }
コード例 #7
0
        public IActionResult Add(Patient patient)
        {
            var result = _patientService.Add(patient);

            if (result.Success)
            {
                return(Ok(result.Message));
            }
            return(BadRequest(result.Message));
        }
コード例 #8
0
        public async Task <IActionResult> Add([FromBody] PatientRequest request)
        {
            var outputHandler = await _service.Add(request);

            if (outputHandler.IsErrorOccured)
            {
                return(BadRequest(outputHandler.Message));
            }
            return(Created("", outputHandler.Message));
        }
コード例 #9
0
        public IActionResult Index([FromBody] PatientCreationModel newPatient)
        {
            if (ModelState.IsValid)
            {
                var patientInfo = patientService.Add(newPatient);
                return(Ok(patientInfo));
            }

            return(BadRequest(ModelState));
        }
コード例 #10
0
        public async Task <Object> Put(string token, [FromBody] Location location)
        {
            //var stream = "[encoded jwt]";
            var handler   = new JwtSecurityTokenHandler();
            var jsonToken = handler.ReadToken(token);
            var tokenS    = handler.ReadToken(token) as JwtSecurityToken;

            var jti = tokenS.Claims.First(claim => claim.Type == "role").Value;

            return(await PatientService.Add(Int32.Parse(jti), location));
        }
コード例 #11
0
 public ActionResult Create(Patient patient)
 {
     if (patient != null)
     {
         if (!string.IsNullOrEmpty(patient.patientName) || !string.IsNullOrWhiteSpace(patient.patientName))
         {
             _patientService.Add(patient);
             _logger.LogInformation("New patient was added!");
         }
     }
     return(RedirectToAction(nameof(Index)));
 }
コード例 #12
0
 public async Task Add(PatientViewModel patientViewModel)
 {
     try
     {
         // local time zone offset as TimeSpan object
         // add the offsetTime to the datetime recieved as UTC
         var patient = _mapper.Map <PatientViewModel, Patient>(patientViewModel);
         await _patientService.Add(patient);
     }
     catch (Exception exp)
     {
         Console.WriteLine(exp);
     }
 }
コード例 #13
0
        public CommonResponse Add(PatientViewModel patientViewModel)
        {
            CommonResponse <PatientViewModel> response = new CommonResponse <PatientViewModel>();

            try
            {
                var model = _patientService.Add(_mapper.Map <Patient>(patientViewModel));
                response.Result = _mapper.Map <PatientViewModel>(model);
            }
            catch (ServiceException ex)
            {
                response.StatusText = ex.Message;
            }
            return(response);
        }
コード例 #14
0
 public void Post([FromBody] PatientViewModel model)
 {
     if (ModelState.IsValid)
     {
         patientService.Add(new WebApp.Services.Models.Patient()
         {
             Address    = model.Address,
             Email      = model.Email,
             Gender     = model.Gender,
             Name       = model.Name,
             PatientNbr = model.PatientNbr,
             PhoneNbr   = model.PhoneNbr
         });
     }
 }
コード例 #15
0
        public IActionResult Index(PatientViewModel model)
        {
            if (ModelState.IsValid)
            {
                patientService.Add(new Patient()
                {
                    Address    = model.Address,
                    Email      = model.Email,
                    Name       = model.Name,
                    PatientNbr = model.PatientNbr,
                    PhoneNbr   = model.PhoneNbr,
                    Gender     = model.Gender
                });
            }

            return(View(model));
        }
コード例 #16
0
        private void AddPatient()
        {
            Console.Clear();
            Console.WriteLine("First Name:");
            var firtsName = Console.ReadLine();

            Console.WriteLine("Last Name:");
            var lastName = Console.ReadLine();

            Console.WriteLine("Age:");
            var answer = Console.ReadLine();

            int age;
            var result = Int32.TryParse(answer, out age);

            if (result)
            {
                Console.WriteLine("Doctor:");
                answer = Console.ReadLine();

                int id;
                result = Int32.TryParse(answer, out id);
                if (result)
                {
                    var patientId = patients.GetMaxId() + 1;
                    patients.Add(new Patient()
                    {
                        FirstName = firtsName,
                        LastName  = lastName,
                        Id        = patientId,
                        Age       = age,
                        DoctorId  = id
                    });
                }
                else
                {
                    Console.WriteLine("Incorrect input of doctor's identificator!");
                }
            }
            else
            {
                Console.WriteLine("Incorrect input of age!");
            }
        }
コード例 #17
0
        public HttpResponseMessage Create(HttpRequestMessage request, PhieuSangLocViewModel phieuSangLocVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu);
                    if (phieuDB != null)
                    {
                        phieuDB.UpdatePhieuSangLoc(phieuSangLocVm);
                        var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan);
                        patientDB.UpdatePatient(phieuSangLocVm);

                        this.phieuSangLocService.Update(phieuDB);
                        this.patientService.Update(patientDB);
                        donViCoSoService.Save();

                        response = request.CreateResponse(HttpStatusCode.OK);
                    }
                    else
                    {
                        var newPhieu = new PhieuSangLoc();
                        newPhieu.UpdatePhieuSangLoc(phieuSangLocVm);
                        ApplicationUser user = this.userManager.FindByNameAsync(phieuSangLocVm.Username).Result;
                        newPhieu.IDNhanVienTaoPhieu = user.Id;
                        var newPatient = new Patient();
                        newPatient.UpdatePatient(phieuSangLocVm);
                        newPhieu.MaBenhNhan = Guid.NewGuid().ToString();
                        newPatient.MaBenhNhan = newPhieu.MaBenhNhan;
                        phieuSangLocService.Add(newPhieu);
                        patientService.Add(newPatient);
                        phieuSangLocService.Save();
                        response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm);
                    }
                }

                return response;
            }));
        }
コード例 #18
0
 public async Task Add(PatientDto patientDto)
 {
     try
     {
         if (patientDto.FirstName == "Test")
         {
             throw new Exception("Name can not be Test");
         }
         // local time zone offset as TimeSpan object
         // add the offsetTime to the datetime recieved as UTC
         var patient = _mapper.Map <PatientDto, Patient>(patientDto);
         await _patientService.Add(patient);
     }
     catch (Exception exp)
     {
         Console.WriteLine(exp);
         throw;
     }
 }
コード例 #19
0
ファイル: PatientController.cs プロジェクト: Emanuel82/Obalon
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                bool gender   = collection["Gender"] == "Male";
                int  heightFt = Int32.Parse(collection["heigthFt"]);
                int  heightIn = Int32.Parse(collection["heightIn"]);

                int age = Int32.Parse(collection["years"]);

                patientService.Add(new Patient()
                {
                    Gender = gender, HeightFt = heightFt, HeightIn = heightIn, Age = age
                });

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #20
0
 public IHttpActionResult Post(PatientDto patientDto)
 {
     patientService.Add(patientDto);
     return(Created("", patientDto));
 }
コード例 #21
0
 public async Task AddPatient([FromBody] PatientDTO patientDTO)
 {
     await _patientService.Add(patientDTO);
 }
コード例 #22
0
 public IActionResult Add(GuestPatientDTO guestPatient)
 {
     _service.Add(guestPatient);
     return(NoContent());
 }
コード例 #23
0
        public JsonResult Post([FromBody] ContractRequest <AddUpdatePatientRequest> request)
        {
            var patientsResponse = _patientService.Add(request);

            return(Json(patientsResponse));
        }
コード例 #24
0
 public ContentResult CreatePatient(Patient patient)
 {
     patientService.Add(patient);
     patientService.Save();
     return(Content("<p>The patient was created successfully!</p>"));
 }