コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public IActionResult CreatePatient([FromBody] CreatePatientViewModel createPatientViewModel)
        {
            var patientDTO = PatientMapper.CreatePatientVMToDTO(createPatientViewModel);

            _service.Create(patientDTO);

            return(Ok(ModelState));
        }
コード例 #5
0
 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 }));
 }
コード例 #6
0
ファイル: PatientController.cs プロジェクト: jakarlse88/p10
        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));
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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 }));
            }
        }
コード例 #9
0
        public IActionResult Post([FromBody] PatientModel param)
        {
            AssignModelState();

            var res = _patientService.Create(param);

            if (res.Success)
            {
                return(Ok(res.Item));
            }
            else
            {
                return(BadRequest(res.Message));
            }
        }
コード例 #10
0
        //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));
            }
        }
コード例 #11
0
 public JsonResult AddOrEdit(Patient Model)
 {
     if (ModelState.IsValid)
     {
         if (Model.Id == 0)
         {
             patientService.Create(Model);
         }
         else
         {
             patientService.Update(Model);
         }
     }
     return(Json(1));
 }
コード例 #12
0
        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"));
        }
コード例 #13
0
ファイル: PatientController.cs プロジェクト: Thraxs/NtTracker
        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"));
        }
コード例 #14
0
        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()));
        }
コード例 #15
0
        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()));
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
        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"));
        }
コード例 #18
0
        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"));
        }
コード例 #19
0
        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);
            }
        }
コード例 #20
0
        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!" }));
        }
コード例 #21
0
 public ActionResult CreatePatient(PatientViewModel patient)
 {
     _patientService.Create(patient);
     return(RedirectToAction("Patients"));
 }
コード例 #22
0
 public PatientDto Create([FromBody] PatientDto data)
 {
     return(_service.Create(data));
 }
コード例 #23
0
ファイル: PatientController.cs プロジェクト: sanchezzz41/Emr
 public async Task <Guid> Create(PatientInfo infoModel)
 {
     return(await _patientService.Create(infoModel));
 }
コード例 #24
0
        public async Task <ActionResult> Post([FromBody] CreatePatientRequest request)
        {
            var response = await _patientService.Create(request);

            return(GetApiResponse(response));
        }
コード例 #25
0
        public bool Post([FromBody] Patient value)
        {
            var result = _patientService.Create(value);

            return(result);
        }