public void Save()
 {
     if (CheckData() && !CheckDoppione())
     {
         PatientService service = new PatientService();
         if ((this.DataContext as PatientEntity).Id == -1)
         {
             if (service.Add(this.DataContext as PatientEntity) == 0)
             {
                 MessageBox.Show("Salvato!");
                 this.DataContext = new PatientEntity();
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
         else
         {
             if (service.Update(this.DataContext as PatientEntity) == 0)
             {
                 MessageBox.Show("Salvato!");
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
     }
 }
        public async Task <IActionResult> Edit(AdminPatientDto model)
        {
            if (!ModelState.IsValid)
            {
                await ShowHospitalList(false);
                await ShowDoctorList(true, model.HospitalId);

                ViewBag.SexList        = EnumExtensionHelper.EnumToSelectList <SexEnum>(false);
                ViewBag.UserStatusList = EnumExtensionHelper.EnumToSelectList <UserStatusEnum>(false);
                return(PartialView("_EditPartial", model));
            }

            if (model.HospitalId < 1 && !CurrentLoginUser.IsSuperManager)
            {
                model.HospitalId = CurrentLoginUser.HospitalId.Value;
            }

            //主键初始Id大于0表示是编辑,反之则是新增
            if (model.Id > 0)
            {
                var result = await _service.Update(model);

                return(Json(result));
            }
            else
            {
                var result = await _service.Add(model);

                return(Json(result));
            }
        }
Ejemplo n.º 3
0
        public ActionResult AddPatient(PatientModel model)
        {
            #region testing code should be delete
            //var model=new PatientModel(){
            //    BranchId=1,
            //    Name="firstTestPatient",
            //    Email="*****@*****.**",
            //    GenderId=1,
            //    DateofBirth=DateTime.Now,
            //    PhoneNumber="987987697",
            //    ReferredId=-1
            //};
            #endregion
            if (model.PatientTestIds.Count > 0)
            {
                int UserId = Convert.ToInt32(Session["loginuser"].ToString());
                model.BranchId = UserServices.GetUserBranch(UserId).Id;
                PatientServices.Add(model);

                foreach (var TestId in model.PatientTestIds)
                {
                    PatientTestService.Add(new PatientTest
                    {
                        PatientId         = model.Id,
                        TestSubcategoryId = TestId
                    });
                }
                return(Json("SuccessFully Added Patient", JsonRequestBehavior.AllowGet));
            }
            return(Json("Please assign tests for patients", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public HttpResponseMessage Add(PatientDto newPatientDto)
        {
            var userId = UserIdentity.GetUserId((ClaimsIdentity)User.Identity);
            var result = _services.Add(newPatientDto, userId);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Ejemplo n.º 5
0
        public ActionResult MigrateData(string fileName)
        {
            MigrationViewModel migrationViewModel = ReadData(fileName);
            //PostgreSQL operations
            var  practices = PracticeService.Get();
            Guid practiceId;

            if (practices != null && practices.Count() > 0)
            {
                practiceId = practices.First().Id;
            }
            else
            {
                var practice = new Practices()
                {
                    Name         = "DemoPractice",
                    Email        = "*****@*****.**",
                    Abn          = "S2C2343242",
                    Id           = Guid.NewGuid(),
                    Timezone     = "AEST",
                    PracticeType = "Full",
                    CreatedAt    = DateTime.Now,
                    UpdatedAt    = DateTime.Now,
                    LocationCode = "AUS",
                    StateId      = new Guid("641d6b03-7417-4278-947f-5eb7f732e40e")
                };
                var addedPractice = PracticeService.Add(practice);
                practiceId = addedPractice.Id;
            }
            var inputModel = migrationViewModel.MigrationPatients.First();
            var contacts   = new List <EmergencyContacts>();

            contacts.Add(new EmergencyContacts()
            {
                FirstName    = "Bhavik",
                LastName     = "Patel",
                PhoneNumber  = "12123123123",
                Relationship = "Friend",
                PracticeId   = practiceId
            });
            var patientModel = new Patients()
            {
                FirstName         = inputModel.FirstName,
                MiddleName        = inputModel.MiddleName,
                LastName          = inputModel.LastName,
                MaidenName        = inputModel.MaidenName,
                Email             = inputModel.Email,
                EmergencyContacts = contacts,
                PracticeId        = practiceId
            };
            var addedPatient = PatientService.Add(patientModel);

            migrationViewModel.Message = "Data migrated successfully";
            return(View("Index", migrationViewModel));
        }
Ejemplo n.º 6
0
        public void AddPatient_WithInvalidOIB2()
        {
            string street  = "Unska 3";
            string city    = "Zagreb";
            string zipcode = "10000";

            var            mockRepository = new Mock <IPatientRepository>();
            PatientService patientService = new PatientService(mockRepository.Object);

            patientService.Add("Ivo", "Ivić", "23R456a7890", DateTime.Now, "ii01234", street, city, zipcode);
        }
Ejemplo n.º 7
0
        public void CanRemovePatientById()
        {
            //Arrange
            Patient            patient        = new Patient(1, "aaa", "bbb", "ccc", 123, "ddd");
            IService <Patient> patientService = new PatientService();

            patientService.Add(patient);

            var manager = new PatientManager(patientService);

            //Act
            manager.Remove(patient.Id);
            //Assert
            patientService.GetAll().Count.Should().Equals(0);
        }
Ejemplo n.º 8
0
        public void AddPatient()
        {
            Patient patient = new Patient("Ivo", "Ivić", "23456117890", DateTime.Now, "ii01234");
            string  street  = "Unska 3";
            string  city    = "Zagreb";
            string  zipcode = "10000";


            var mockRepository = new Mock <IPatientRepository>();

            mockRepository.Setup(x => x.Add(It.IsAny <Patient>())).Returns(patient);
            PatientService patientService = new PatientService(mockRepository.Object);

            patientService.Add("Ivo", "Ivić", "23456117890", DateTime.Now, "ii01234", street, city, zipcode);

            mockRepository.Verify(x => x.Add(patient), Times.Once());
        }
Ejemplo n.º 9
0
        public void Web_Service_For_Adding_Patient()
        {
            // pick a device to test
            var device = new LinqMetaData().Device.FirstOrDefault(x => x.ScansAvailable > 0);

            Assert.IsNotNull(device);

            // setup service call
            var output  = new StringWriter();
            var service = new PatientService();
            var url     = new Uri("http://localhost/" + service.GetProperties().Url + "/add", UriKind.Absolute);

            HttpContext.Current = new HttpContext(
                new HttpRequest(url.AbsolutePath, url.AbsoluteUri, url.Query),
                new HttpResponse(output));
            HttpContext.Current.User = new RolePrincipal(new GenericIdentity(device.UniqueIdentifier));
            Thread.CurrentPrincipal  = HttpContext.Current.User;

            // report the completed scan
            var patient = service.Add(new Patient
            {
                BirthDate     = DateTime.UtcNow.AddYears(-18),
                EmailAddress  = "*****@*****.**",
                FirstName     = "TestFirst",
                LastName      = "TestLast",
                Gender        = Gender.Male,
                Guid          = Guid.NewGuid().ToString(),
                MiddleInitial = "T",
                PhoneNumber   = "555-555-5555"
            });

            // make sure patient was added
            var testPatient = new LinqMetaData().Patient.FirstOrDefault(x => x.BirthDate == patient.BirthDate);

            Assert.IsNotNull(testPatient);

            // update the patient information
            patient.BirthDate = DateTime.UtcNow.AddYears(-18);
            service.Update(patient);
            testPatient = new LinqMetaData().Patient.FirstOrDefault(x => x.BirthDate == patient.BirthDate);
            Assert.IsNotNull(testPatient);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Edit(AdminPatientDto model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_EditPartial", model));
            }

            //主键初始Id大于0表示是编辑,反之则是新增
            if (model.Id > 0)
            {
                var result = await _service.Update(model);

                return(Json(result));
            }
            else
            {
                var result = _service.Add(model);
                return(Json(result));
            }
        }
Ejemplo n.º 11
0
        public ActionResult AddPatient(PatientModel model)
        {
            #region temp code this must be removed
            //PatientPaymentServices.AddPayType(new PayType
            //{
            //    Description = "Card"
            //});
            //PatientPaymentServices.AddPayType(new PayType
            //{
            //    Description = "Cash"
            //});
            #endregion
            #region testing code should be delete
            //var model=new PatientModel(){
            //    BranchId=1,
            //    Name="firstTestPatient",
            //    Email="*****@*****.**",
            //    GenderId=1,
            //    DateofBirth=DateTime.Now,
            //    PhoneNumber="987987697",
            //    ReferredId=-1
            //};
            #endregion

            if (model.PatientTestIds.Count > 0)
            {
                int UserId = Convert.ToInt32(Session["loginuser"].ToString());
                var branch = UserServices.GetUserBranch(UserId);
                model.BranchId = branch.Id;
                model.Age      = (DateTime.Now.Year - model.DateofBirth.Year).ToString();

                PatientServices.Add(model);
                List <TestSubcategory> selectedTests = new List <TestSubcategory>();
                double netAmount = 0;
                foreach (var TestId in model.PatientTestIds)
                {
                    PatientTestService.Add(new PatientTest
                    {
                        PatientId         = model.Id,
                        TestSubcategoryId = TestId
                    });
                    var test = TestSubCategoryServices.getById(TestId);
                    selectedTests.Add(test);
                    netAmount = netAmount + test.Rate;
                }

                if (model.Discount > 0)
                {
                    netAmount = netAmount - model.Discount;
                }

                PatientPaymentServices.Add(new Payment
                {
                    PatientId   = model.Id,
                    PatientName = model.Name,
                    PaidAmount  = model.PaidAmount,
                    Discount    = model.Discount,
                    NetAmount   = netAmount,
                    Balance     = netAmount - model.PaidAmount,
                    PayTypeId   = model.PayId
                });

                var gender = GenderServices.GetById(model.GenderId);

                model.Genders.Add(new SelectListItem
                {
                    Text = gender.GenderDescription
                });

                var referdoctor = ReferDoctorsServices.GetReferDoctorById(model.ReferredId);

                model.ReferredDoctors.Add(new SelectListItem
                {
                    Text = referdoctor.ReferredDoctorName
                });
                var branchContact = BranchServices.GetBranchContact(branch.Id);
                GeneratePatientRecipt(model, gender, selectedTests, branch, branchContact);

                return(Json("SuccessFully Added Patient", JsonRequestBehavior.AllowGet));
            }
            return(Json("Please assign tests to patients", JsonRequestBehavior.AllowGet));
        }