Ejemplo n.º 1
0
        public Patient Add(Patient person)
        {
            var toEntity = person.ToEntity();

            _patientRepository.Add(toEntity);
            return(person);
        }
Ejemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            var DBFactory = new AppDbContextFactory();

            using (AppDbContext dBContext = DBFactory.CreateDbContext(args))
            {
                IPatientRepository patient = new PatientRepository(dBContext);
                try
                {
                    patient.Add(new Patient
                    {
                        Name            = "Liam",
                        Surname         = "Hyde",
                        InsuranceNumber = "0000000022",
                        RegionId        = 3,
                    });
                }catch (DbUpdateException e)
                {
                    Console.WriteLine("Pizdec \n" + e);
                }
            }
            using (AppDbContext dBContext = DBFactory.CreateDbContext(args))
            {
                IPatientRepository patient = new PatientRepository(dBContext);

                foreach (Patient patients in patient.GetAllAsync().Result)
                {
                    Console.WriteLine($"{patients.Name} {patients.Surname} lives in Region");
                }
            }
        }
Ejemplo n.º 3
0
        public Patient CreatePatient(User doctor)
        {
            var patient = new Patient();

            PatientRepository.Add(patient);

            //verify that patient number is unique
            //if it is not, then assign unique number
            var maxNumber = PatientRepository.GetMaxPatientNumber();

            patient.PatientNumber = maxNumber + 1;
            patient.Caption       = string.Format("Subj {0}{1:D3}", "A", patient.PatientNumber);
            patient.Doctor        = doctor;
            doctor.Patients.Add(patient);

            patient.Visits = new List <Visit>();
            patient.Visits.Add(CreateBaselineVisit(patient));
            patient.Visits.Add(Create1stDayVisit(patient));
            patient.Visits.Add(Create10thDayVisit(patient));
            foreach (var visit in patient.Visits)
            {
                VisitRepository.Add(visit);
                foreach (var form in visit.Forms)
                {
                    FormRepository.Add(form);
                }
            }

            return(patient);
        }
        public void TestCreatePatient()
        {
            PatientRepository patientRepository = new PatientRepository();
            Patient           patient1          = new Patient("id1", "name1", 1);

            Assert.AreEqual(patientRepository.PatientsCount, 0);

            patientRepository.Add(patient1);

            Assert.AreEqual(patientRepository.PatientsCount, 1);
            Assert.AreEqual(patientRepository.GetByID(patient1.ID), patient1);

            patientRepository.Add(new Patient("id2", "name2", 2));

            Assert.AreEqual(patientRepository.PatientsCount, 2);
        }
Ejemplo n.º 5
0
        public void Can_UpdateInfo_About_Patient()
        {
            Patient patient = new Patient()
            {
                fam = "TEST_UPDATE",
                im  = "TEST_UPDATE",
                ot  = "TEST_UPDATE",
                dr  = DateTime.Now,
                sex = 1
            };

            _patientRepository = new PatientRepository(_connectionString);

            int insertedId = _patientRepository.Add(patient);

            Assert.True(insertedId > 0, "Error Add Patient");

            patient.IdentId = insertedId;

            patient.fam = "TEST_UPDATE2";
            patient.im  = "TEST_UPDATE2";
            patient.ot  = "TEST_UPDATE2";

            _patientRepository.Edit(patient);
        }
Ejemplo n.º 6
0
        public ActionResult New(PatientViewModel patientViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var patient = Mapper.Map <Patient>(patientViewModel);
                    patientRepository.Add(patient);

                    TempData["Title"]   = "Sucesso";
                    TempData["Message"] = "Paciente cadastrado com sucesso.";

                    return(RedirectToAction("Index", "Home"));
                }
                catch (System.Exception ex)
                {
                    TempData["Title"]   = "Erro";
                    TempData["Message"] = $"Ocorreu um erro ao tentar cadastrar o paciente. {ex.Message}";

                    return(View());
                }
            }

            return(View());
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Signup(LoginRegisterViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.RegisterViewModel.Email,
                    Email     = model.RegisterViewModel.Email,
                    FirstName = model.RegisterViewModel.FirstName,
                    LastName  = model.RegisterViewModel.LastName,
                };

                // Add the Address properties:



                var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password);

                dynamic addedResult;
                if (result.Succeeded)
                {
                    SessionHandler.UserName = model.RegisterViewModel.Email;
                    SessionHandler.Password = model.RegisterViewModel.Password;
                    SessionHandler.UserId   = user.Id;


                    PatientRepository objRepo = new PatientRepository();
                    Patient           obj     = new Patient
                    {
                        userId    = user.Id,
                        lastName  = user.LastName,
                        firstName = user.FirstName,
                        email     = user.Email
                    };
                    addedResult = objRepo.Add(obj);

                    if (addedResult != null)
                    {
                        //ViewBag.SuccessMessage = "Your Account has been created, please login";
                        ViewBag.SuccessMessage = "Your Account has been created, please login";
                        return(View("PatientLogin", model));
                    }
                }
                AddErrors(result);
                foreach (var item in result.Errors)
                {
                    error += item;
                    break;
                }
            }

            // If we got this far, something failed, redisplay form
            //return View("PatientLogin", model);
            TempData["error"]   = error;
            ViewBag.ModelError += "\n" + error;
            return(Redirect(Url.Action("PatientLogin", "Account") + "#signup"));
        }
Ejemplo n.º 8
0
        public async void AddPatient_Successful_Test()
        {
            var patient = new Patient {
                Id = 1, IsLock = false, Firstname = "Иван", Lastname = "Иванов", Middlename = "Иванович", DoctorId = 1
            };

            var patients = await _patientRepository.GetPatientsRepositoryAsync(PatientsType.AllPatients);

            Assert.Empty(patients);

            _patientRepository.Add(patient);
            await _patientRepository.SaveAllAsync();

            patients = await _patientRepository.GetPatientsRepositoryAsync(PatientsType.AllPatients);

            Assert.Single(patients);
            Assert.Equal(1, patients.FirstOrDefault().Id);
        }
Ejemplo n.º 9
0
        public IActionResult Post(Patient patient)
        {
            var currentUser = GetCurrentUser();

            patient.UserProfileId = currentUser.Id;

            _patientRepository.Add(patient);
            return(CreatedAtAction("Get", new { id = patient.Id }, patient));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Add Patient
 /// </summary>
 /// <param name="patient">Patient to add</param>
 /// <returns></returns>
 public bool Add(Patient patient)
 {
     //Search if the patient exists and if not add the patient.
     if (patientRepository.Search(patient.Id) == null)
     {
         patientRepository.Add(patient);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
        public void AddTest()
        {
            doctorRepository.Add(doctor);
            patientRepository.Add(patient);
            sessionrepository.Add(session);
            bool result = dbContext.SaveChanges() > 2;

            Assert.IsTrue(result);
            Transaction.Current.Rollback();
        }
        public Patient AddPatient(string id, string name, int age)
        {
            Patient patient = new Patient();

            patient.ID   = id;
            patient.Name = name;
            patient.Age  = age;

            patientRepository.Add(patient);
            return(patient);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 同步患者
        /// </summary>
        /// <param name="sync"></param>
        /// <returns></returns>
        public async Task <OutputBase> AddOrUpdate(AddPatientSync sync)
        {
            var patient = await _repository.Get(sync.DialysisPatientId, sync.HospitalId);

            if (patient == null)
            {
                patient = Mapper.Map <AddPatientSync, Patient>(sync);
                _repository.Add(patient);
            }
            else
            {
                patient.UpdateTime = DateTime.Now;
                Mapper.Map(sync, patient);
            }
            if (sync.PatientFace != null && sync.PatientFace.Length > 0)
            {
                patient.PatientFace = await _ossRepository.UploadPatientAvatar(patient.Id, sync.PatientFace);
            }

            return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败"));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 新增患者
        /// </summary>
        /// <param name="input">患者信息</param>
        /// <returns>是否成功</returns>
        public OutputBase Add(AdminPatientDto input)
        {
            var patient = new Patient
            {
                Brithdate   = input.Brithdate,
                PatientName = input.PatientName,
                Sex         = input.Sex,
            };
            var patientId = _repository.Add(patient);

            return(_unitWork.Commit() ? OutputBase.Success("新增成功") : OutputBase.Fail("新增失败"));
        }
Ejemplo n.º 15
0
        public void CreateAdd()
        {
            var patient  = new Patient("Ivan", "Ivanov", "KI55000", "+375152996");
            var patient1 = new Patient("Petr", "Sergeev", "KH1234311", "+375291545");

            var doctor = new Doctor("Platon", "Sidorov", "Therapist");

            var car = new MedicalCar("Mercedes Benz Sprinter 412", "12.05.2009", "VBGTF48483D6");

            var call  = new Call(new DateTime(2015, 3, 15));
            var call1 = new Call(new DateTime(2015, 3, 16));

            var waybill = new Waybill(new DateTime(2015, 3, 16));

            doctor.Patients.Add(patient);
            doctor.Patients.Add(patient1);
            doctor.Car.Add(car);

            car.Doctors.Add(doctor);
            car.Waybills.Add(waybill);

            call.Patient.Add(patient);
            call.Waybill = waybill;

            call1.Patient.Add(patient1);
            call1.Waybill = waybill;

            waybill.Car = car;
            waybill.Calls.Add(call);
            waybill.Calls.Add(call1);

            patient.Call   = call;
            patient.Doctor = doctor;

            patient1.Call   = call1;
            patient1.Doctor = doctor;

            using (var context = new DataContext())
            {
                context.Database.CreateIfNotExists();

                // context.Database.Delete();
                BaseRepository <Call>       calls       = new CallRepository(context);
                BaseRepository <Doctor>     doctors     = new DoctorRepository(context);
                BaseRepository <MedicalCar> medicalCars = new MedicalCarRepository(context);
                BaseRepository <Patient>    patients    = new PatientRepository(context);
                BaseRepository <Waybill>    waybills    = new WaybillRepository(context);

                patients.Add(patient1);
                patients.Save();
            }
        }
Ejemplo n.º 16
0
        public void CanAddNewPatient()
        {
            var repo    = new PatientRepository();
            var patient = new Patient
            {
                Address =
                    new Address
                {
                    Street1 = "123 Main Street",
                    City    = "Accra",
                    Region  = "Greater Accra",
                    //Country = "Ghana",
                    IsActive = true
                },
                //Allergies = new List<Allergy> {new Allergy {Name = "Peanut Butter"}},
                DateOfBirth = new DateTime(1980, 03, 17),
                //BloodType = "O+",
                Gender           = Gender.Male,
                FirstName        = "Matthew",
                MiddleName       = "Scott",
                LastName         = "Kimber",
                EmergencyContact = new EmergencyContact
                {
                    FirstName    = "Jan",
                    LastName     = "Kimber",
                    PhoneNumber  = "801-479-1717",
                    Relationship = Relationship.Mother,
                    Address      =
                        new Address
                    {
                        Street1 = "1288 E. 4790 N.",
                        City    = "Ogden",
                        Region  = "Utah",
                        //Country = "USA"
                    }
                },
                PhoneNumber = "801-726-8585"
                              //Religion = "Muslim",
                              //TribeRace = "Anglo-Saxon"
            };

            repo.Add(patient);

            UnitOfWork.CurrentSession.Flush();
            UnitOfWork.CurrentSession.Clear();

            repo.Get(100002);
        }
Ejemplo n.º 17
0
        public void CanAddNewPatient()
        {
            var repo = new PatientRepository();
            var patient = new Patient
                              {
                                  Address =
                                      new Address
                                          {
                                              Street1 = "123 Main Street",
                                              City = "Accra",
                                              Region = "Greater Accra",
                                              //Country = "Ghana",
                                              IsActive = true
                                          },
                                  //Allergies = new List<Allergy> {new Allergy {Name = "Peanut Butter"}},
                                  DateOfBirth = new DateTime(1980, 03, 17),
                                  //BloodType = "O+",
                                  Gender = Gender.Male,
                                  FirstName = "Matthew",
                                  MiddleName = "Scott",
                                  LastName = "Kimber",
                                  EmergencyContact = new EmergencyContact
                                                         {
                                                             FirstName = "Jan",
                                                             LastName = "Kimber",
                                                             PhoneNumber = "801-479-1717",
                                                             Relationship = Relationship.Mother,
                                                             Address =
                                                                 new Address
                                                                     {
                                                                         Street1 = "1288 E. 4790 N.",
                                                                         City = "Ogden",
                                                                         Region = "Utah",
                                                                         //Country = "USA"
                                                                     }
                                                         },
                                  PhoneNumber = "801-726-8585"
                                  //Religion = "Muslim",
                                  //TribeRace = "Anglo-Saxon"
                              };

            repo.Add(patient);

            UnitOfWork.CurrentSession.Flush();
            UnitOfWork.CurrentSession.Clear();

            repo.Get(100002);
        }
Ejemplo n.º 18
0
        public void Can_Add_Patient()
        {
            _patientRepository = new PatientRepository(_connectionString);

            int insertedID = _patientRepository.Add(
                new Patient()
            {
                fam = "TEST",
                im  = "TEST",
                ot  = "TEST",
                dr  = DateTime.Now,
                sex = 1
            }
                );

            Assert.True(insertedID > 0, "Error Add Patient");
        }
Ejemplo n.º 19
0
        public void AddTest()
        {
            //Arrange
            PatientRepository Pr = new PatientRepository();

            //Act
            var patient = new Patient();

            patient.FirstName = "John";
            Pr.Add(patient);

            var expected = "John";
            var actual   = Pr.GetAllPatients().Last().FirstName;

            //Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 20
0
        private void AddPatient(object obj)
        {
            UpdateCheckAmount();
            RaisePropertyChanged("CheckAmount");

            if (Settings.ReuseSamePatientEnabled)
            {
                GetNewPatientDependentOnUserPromptPreference();
            }

            else if (Settings.ReuseSamePatientEnabled == false)
            {
                Patient = new Patient();
            }
            RaisePropertyChanged("Patient");
            patientRepository.Add(Patient);
            RefreshAllCounters();
        }
Ejemplo n.º 21
0
        public IHttpActionResult PostPatients(Patients patients)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            // Existing patient validation
            Patients _patient = repository.GetAll().Where(p => p.idPatient == patients.idPatient).FirstOrDefault();

            if (_patient != null)
            {
                return(BadRequest());
            }

            repository.Add(patients);
            //db.Patients.Add(patients);
            //db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = patients.idPatient }, patients));
        }
Ejemplo n.º 22
0
        public void Can_GetPatientInfo_Byid()
        {
            Patient patient = new Patient()
            {
                fam = "TEST_Info",
                im  = "TEST_Info",
                ot  = "TEST_Info",
                dr  = DateTime.Now,
                sex = 1
            };

            _patientRepository = new PatientRepository(_connectionString);

            int insertedId = _patientRepository.Add(patient);

            Assert.True(insertedId > 0, "Error Add Patient");

            Patient patientById = _patientRepository.GetPatientById(insertedId);

            Assert.Equal(insertedId, patientById.IdentId);
        }
Ejemplo n.º 23
0
        public string Create(Patient patient)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    objRepo.Add(patient);
                    return("1");
                }
                else
                {
                    return("0");
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());

                throw ex;
            }

            //return Json(objRepo.GetAll().ToList(), JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 24
0
        private void SavePatient(object sender, EventArgs e)
        {
            if (btnSave.Text == "Edit")
            {
                var existingPatient = patientRepository.GetById(patientId);
                existingPatient.LastName      = txtLastName.Text;
                existingPatient.FirstName     = txtFistName.Text;
                existingPatient.Gender        = txtGender.Text;
                existingPatient.BirthDate     = txtBirthDate.Text;
                existingPatient.Occupation    = txtOccupation.Text;
                existingPatient.Email         = txtEmail.Text;
                existingPatient.ContactNumber = txtContactNumber.Text;

                if (patientRepository.Update(existingPatient) > 0)
                {
                    MessageBox.Show("Updated successfully");
                }
            }
            else
            {
                var patient = new Patient();
                patient.LastName      = txtLastName.Text;
                patient.FirstName     = txtFistName.Text;
                patient.Gender        = txtGender.Text;
                patient.BirthDate     = txtBirthDate.Text;
                patient.Occupation    = txtOccupation.Text;
                patient.Email         = txtEmail.Text;
                patient.ContactNumber = txtContactNumber.Text;

                if (patientRepository.Add(patient) > 0)
                {
                    MessageBox.Show("Saved succesfully");
                }
            }

            FillDataGridView();
        }
Ejemplo n.º 25
0
        public IActionResult AddPatient([FromBody] Patient patient)
        {
            var addedPatient = patientRepository.Add(patient);

            return(Ok(addedPatient));
        }
Ejemplo n.º 26
0
        private void btnReservation_Click(object sender, EventArgs e)
        {
            bool allValuesValid = true;

            errorProvider.Clear();

            if (string.IsNullOrEmpty(txtPatientName.Text) || txtPatientName.Text.Length < 3)
            {
                errorProvider.SetError(txtPatientName, "ادخل اسم صحيح");
                allValuesValid = false;
            }
            if (string.IsNullOrEmpty(txtPatientPhone.Text) || !long.TryParse(txtPatientPhone.Text, out var phone) || phone.ToString().Length != 10 || !txtPatientPhone.Text.StartsWith("01"))
            {
                errorProvider.SetError(txtPatientPhone, "ادخل اسم رقم تليفون صحيح");
                allValuesValid = false;
            }
            if (string.IsNullOrEmpty(txtPatientAge.Text) || !int.TryParse(txtPatientAge.Text, out var age) || age > 120 || age < 1)
            {
                errorProvider.SetError(txtPatientAge, "ادخل سن صحيح");
                allValuesValid = false;
            }
            if (string.IsNullOrEmpty(txtPatientAddress.Text))
            {
                errorProvider.SetError(txtPatientAddress, "ادخل عنوان صحيح");
                allValuesValid = false;
            }
            if (dateTimePicker1.Value.Date.CompareTo(DateTime.Now.Date) < 0)
            {
                errorProvider.SetError(dateTimePicker1, "ادخل تاريخ صحيح");
            }

            if (allValuesValid)
            {
                if (PatientId == 0)
                {
                    PatientRepository.Add(
                        new Patient()
                    {
                        Address     = txtPatientAddress.Text,
                        Age         = int.Parse(txtPatientAge.Text),
                        FullName    = txtPatientName.Text,
                        IsExamined  = false,
                        Phone       = txtPatientPhone.Text,
                        Order       = 1,
                        GenderId    = (cmbPatiendGender.SelectedItem as Gender).Id,
                        Appointment = new List <Appointment>()
                        {
                            new Appointment()
                            {
                                Date = dateTimePicker1.Value.Date.ToShortDateString()
                            }
                        }
                    }
                        );
                    PatientRepository.save();
                    ctrMain ctrMain = (ctrMain)ControlForAll;
                    ctrMain.FillDataGridView();
                    this.Close();
                }
                else
                {
                    Patient patient = PatientRepository.Find(PatientId);
                    patient.FullName    = txtPatientName.Text;
                    patient.Phone       = txtPatientPhone.Text;
                    patient.Address     = txtPatientAddress.Text;
                    patient.Age         = Convert.ToInt32(txtPatientAge.Text);
                    patient.GenderId    = (cmbPatiendGender.SelectedItem as Gender).Id;
                    patient.Appointment = new List <Appointment>()
                    {
                        new Appointment()
                        {
                            Date = dateTimePicker1.Value.Date.ToShortDateString()
                        }
                    };
                    PatientRepository.save();
                    if (ControlForAll is ctrMain)
                    {
                        ctrMain ctrMain = (ctrMain)ControlForAll;
                        ctrMain.FillDataGridView();
                        this.Close();
                    }
                    else if (ControlForAll is ctrSearch)
                    {
                        ctrSearch ctrSearch = (ctrSearch)ControlForAll;
                        ctrSearch.FillDataGridViewForSearch();
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 27
0
 public int Create(Patient patient)
 {
     return(myRepository.Add(patient));
 }
        public async Task <Patient> Add(Patient entity)
        {
            await _repository.Add(entity);

            return(entity);
        }
Ejemplo n.º 29
0
        public async Task <ActionResult> Register(LoginRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.RegisterViewModel.Email,
                    Email     = model.RegisterViewModel.Email,
                    FirstName = model.RegisterViewModel.FirstName,
                    LastName  = model.RegisterViewModel.LastName,
                };

                // Add the Address properties:



                var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password);

                dynamic addedResult;
                if (result.Succeeded)
                {
                    SessionHandler.UserName = model.RegisterViewModel.Email;
                    SessionHandler.Password = model.RegisterViewModel.Password;
                    SessionHandler.UserId   = user.Id;

                    if (model.IsPatient)
                    {
                        PatientRepository objRepo = new PatientRepository();
                        Patient           obj     = new Patient
                        {
                            userId    = user.Id,
                            lastName  = user.LastName,
                            firstName = user.FirstName,
                            email     = user.Email
                        };
                        addedResult = objRepo.Add(obj);
                    }
                    else
                    {
                        DoctorRepository objRepo = new DoctorRepository();
                        Doctor           obj     = new Doctor
                        {
                            userId    = user.Id,
                            lastName  = user.LastName,
                            firstName = user.FirstName,
                            email     = user.Email
                        };
                        addedResult = objRepo.Add(obj);
                    }
                    if (addedResult != null)
                    {
                        ViewBag.SuccessMessage = "Your Account has been created, please login";
                        return(View("Login"));
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form

            //return View("Login", model);
            return(View("Login", model));
        }