示例#1
0
 public static void Initialize(ClinicContext context)
 {
     if (!context.Patients.Any())
     {
         context.Patients.AddRange(
             new Patient
         {
             FirstName = "Dauren",
             LastName  = "Dossymbek",
             Address   = "18/1 Syganak str. Apt. 376, Astana, Kazakhstan",
         },
             new Patient
         {
             FirstName = "Frank",
             LastName  = "Collins",
             Address   = "401 Ringgold Rd. Apt. 400, Brownsville, Texas",
         },
             new Patient
         {
             FirstName = "Anton",
             LastName  = "Gribovskiy",
             Address   = "34 University blvd Apt. 78, Edinburg, Texas",
         }
             );
         context.SaveChanges();
     }
 }
示例#2
0
 public AppliedDiagnosController(ClinicContext context)
 {
     _db      = new SQLRepository <AppliedDiagnos>(context);
     _diagdb  = new SQLRepository <Diagnos>(context);
     _appdb   = new SQLRepository <Appointment>(context);
     _context = context;
 }
示例#3
0
        public List <int> SeedPatients(ClinicContext context)
        {
            Random         random       = new Random();
            List <Patient> seedPatients = new List <Patient>();

            seedPatients.Add(new Patient {
                FirstName = "Pedro", MiddleName = "Paricio", LastName = "Panzon", SecondLastName = "Picapiedra", DocumentID = "987654321", Email = "*****@*****.**", BloodType = (BloodType)random.Next(0, Enum.GetNames(typeof(BloodType)).Length), EnrollmentDate = DateTime.Now
            });
            seedPatients.Add(new Patient {
                FirstName = "Juliana", MiddleName = "Solaris", LastName = "Nueva", SecondLastName = "Dehli", DocumentID = "11223344556", Email = "*****@*****.**", BloodType = (BloodType)random.Next(0, Enum.GetNames(typeof(BloodType)).Length), EnrollmentDate = DateTime.Now
            });
            seedPatients.Add(new Patient {
                FirstName = "Pablo", MiddleName = "Clavo", LastName = "Clavito", SecondLastName = "Martillo", DocumentID = "99887766554", Email = "*****@*****.**", BloodType = (BloodType)random.Next(0, Enum.GetNames(typeof(BloodType)).Length), EnrollmentDate = DateTime.Now
            });
            seedPatients.Add(new Patient {
                FirstName = "Kenny", MiddleName = "Bell", LastName = "Maribelle", SecondLastName = "Lit", DocumentID = "123987654", Email = "*****@*****.**", BloodType = (BloodType)random.Next(0, Enum.GetNames(typeof(BloodType)).Length), EnrollmentDate = DateTime.Now
            });
            seedPatients.Add(new Patient {
                FirstName = "Diego", MiddleName = "Tortulio", LastName = "Parra", SecondLastName = "Ayala", DocumentID = "558822334", Email = "*****@*****.**", BloodType = (BloodType)random.Next(0, Enum.GetNames(typeof(BloodType)).Length), EnrollmentDate = DateTime.Now
            });

            context.Patients.AddRange(seedPatients);

            context.SaveChanges();

            return(context.Patients.Select(p => p.PatientId).ToList());
        }
示例#4
0
        public void SeedAppointments(ClinicContext context, List <int> newPatients, List <string> newUsers)
        {
            Random             random           = new Random();
            List <Appointment> seedAppointments = new List <Appointment>();

            seedAppointments.Add(new Appointment {
                AppointmentDate = DateTime.Now.AddDays(1), AppointmentType = (AppointmentType)random.Next(0, Enum.GetNames(typeof(AppointmentType)).Length), PatientId = newPatients[random.Next(0, newPatients.Count)], UserId = newUsers[random.Next(0, newUsers.Count)]
            });
            seedAppointments.Add(new Appointment {
                AppointmentDate = DateTime.Now.AddDays(3), AppointmentType = (AppointmentType)random.Next(0, Enum.GetNames(typeof(AppointmentType)).Length), PatientId = newPatients[random.Next(0, newPatients.Count)], UserId = newUsers[random.Next(0, newUsers.Count)]
            });
            seedAppointments.Add(new Appointment {
                AppointmentDate = DateTime.Now.AddDays(5), AppointmentType = (AppointmentType)random.Next(0, Enum.GetNames(typeof(AppointmentType)).Length), PatientId = newPatients[random.Next(0, newPatients.Count)], UserId = newUsers[random.Next(0, newUsers.Count)]
            });
            seedAppointments.Add(new Appointment {
                AppointmentDate = DateTime.Now.AddDays(7), AppointmentType = (AppointmentType)random.Next(0, Enum.GetNames(typeof(AppointmentType)).Length), PatientId = newPatients[random.Next(0, newPatients.Count)], UserId = newUsers[random.Next(0, newUsers.Count)]
            });
            seedAppointments.Add(new Appointment {
                AppointmentDate = DateTime.Now.AddDays(11), AppointmentType = (AppointmentType)random.Next(0, Enum.GetNames(typeof(AppointmentType)).Length), PatientId = newPatients[random.Next(0, newPatients.Count)], UserId = newUsers[random.Next(0, newUsers.Count)]
            });

            context.Appointments.AddRange(seedAppointments);

            context.SaveChanges();
        }
示例#5
0
        public ActionResult Orders()
        {
            using (ClinicContext db = new ClinicContext())
            {
                var orders = db.Orders
                             .Where(o => o.Date.Year == DateTime.Now.Year)
                             .Select(o => new
                {
                    date  = o.Date,
                    value = db.OrderLines.Where(ol => ol.OrderID == o.ID).Sum(ol => ol.Quantity * ol.Price)
                })
                             .ToList();

                return(Json(
                           orders.GroupBy(o => o.date.Month)
                           .Select(o => new
                {
                    month = o.Key,
                    value = o.Sum(x => x.value)
                })
                           .OrderBy(o => o.month)
                           .ToList(),
                           JsonRequestBehavior.AllowGet
                           ));
            }
        }
示例#6
0
        private void ClinicForm_Load(object sender, EventArgs e)
        {
            using (ClinicContext ctx = new ClinicContext())
            {
                if (!ctx.Database.Exists())
                {
                    MessageBox.Show("Possibly this is the first time the application is being used\n" +
                                    "You need to load the data from a csv file\n\n"
                                    + "GO to Menu bar -> File -> Open ( To open your csv file)\n"
                                    + "The file name: ModifiedHealthCare_2\nThe file location: In the same folder of the application");
                }
            }

            SetupMenu(); // Setup menu when from load

            //Trigger Events for menu bar
            OpenMenu.Click  += MenuActionHandler;
            AboutMenu.Click += MenuActionHandler;
            QuitMenu.Click  += MenuActionHandler;

            // Call the even for each form on load form
            CreateProfileButton.Click   += LoadForm;
            BookAppointmentButton.Click += LoadForm;
            EditAppointmentButton.Click += LoadForm;
            DoctorListButton.Click      += LoadForm;
            CloseButton.Click           += ExitButton_Click;
        }
        private int IsAppointment() // ------- this method is to check that the new date and time the user is setting doesn't exit in the database.
        {
            int c = 0;

            try
            {
                using (var ctx = new ClinicContext())
                {
                    string appointmentTime = AppointmentGridView.Rows[0].Cells[4].Value.ToString(); //geting the appointment time and date
                    string appointmentDate = AppointmentGridView.Rows[0].Cells[3].Value.ToString();
                    //query to check if doctor is available on the entered date and time
                    var appointment = from doct in ctx.Doctors
                                      from appt in ctx.Appointments
                                      where appt.DoctorsId == doct.DoctorsId &&
                                      appointmentDate == appt.AppointmentsDate &&
                                      appointmentTime == appt.AppointmentsTime
                                      select appt;

                    foreach (var item in appointment)
                    {
                        MessageBox.Show("Sorry, Appointment is not available for this date and time!");
                        c = 1;
                        ChangesSavedLabel.Text = "Please check the appointment date and time";
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                MessageBox.Show("There is appointment to be edited");
            }

            return(c);
        }
示例#8
0
        public void Setup()
        {
            var doc = new List <Patient>
            {
                new Patient {
                    PatientId = 1, Name = "Dummy 1", Email = "DD1", Password = "******"
                },
                new Patient {
                    PatientId = 2, Name = "Dummy 2", Email = "DD2", Password = "******"
                },
                new Patient {
                    PatientId = 3, Name = "Dummy 3", Email = "DD3", Password = "******"
                }
            };

            var docdata = doc.AsQueryable();
            var mockSet = new Mock <DbSet <Patient> >();

            mockSet.As <IQueryable <Patient> >().Setup(m => m.Provider).Returns(docdata.Provider);
            mockSet.As <IQueryable <Patient> >().Setup(m => m.Expression).Returns(docdata.Expression);
            mockSet.As <IQueryable <Patient> >().Setup(m => m.ElementType).Returns(docdata.ElementType);
            mockSet.As <IQueryable <Patient> >().Setup(m => m.GetEnumerator()).Returns(docdata.GetEnumerator());

            var mockContext = new Mock <ClinicContext>();

            mockContext.Setup(c => c.Patients).Returns(mockSet.Object);
            db = mockContext.Object;
        }
示例#9
0
 public TruncatedPatient GetPatientById(int id)
 {
     using (ClinicContext context = ClinicContextProvider.GetContext())
     {
         return(truncatedPatientMapper.Map(context.Patients.Where(x => x.Id == id).FirstOrDefault()));
     }
 }
        private void CancelAppointment() //0-------method to cancel an appointment
        {
            try
            {
                int currentAppointmentId = Convert.ToInt32(PatientDatagridViewLookup.Rows[0].Cells[0].Value);

                using (ClinicContext clinicCtx = new ClinicContext())
                {
                    Appointments appointment = (from a in clinicCtx.Appointments
                                                where a.AppointmentId == currentAppointmentId
                                                select a).FirstOrDefault();
                    clinicCtx.Appointments.Remove(appointment);
                    clinicCtx.SaveChanges();

                    ChangesSavedLabel.Visible       = true;
                    ChangesSavedLabel.Text          = "The Appointment was successfully Removed!";
                    CancelAppointmentButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                MessageBox.Show("No appointment to be cancelled");
            }
        }
示例#11
0
 public IEnumerable <TruncatedPatient> GetAllPatients()
 {
     using (ClinicContext context = ClinicContextProvider.GetContext())
     {
         return(context.Patients.ToList().Select(x => truncatedPatientMapper.Map(x)));
     }
 }
示例#12
0
        public ActionResult Sales()
        {
            using (ClinicContext db = new ClinicContext())
            {
                var sales = db.Sales
                            .Where(s => s.Date.Year == DateTime.Now.Year)
                            .Select(s => new
                {
                    date  = s.Date,
                    value = db.SaleLines.Where(sl => sl.SaleID == s.ID).Sum(sl => sl.Quantity * sl.Price)
                })
                            .ToList();

                return(Json(
                           sales.GroupBy(s => s.date.Month)
                           .Select(s => new
                {
                    month = s.Key,
                    value = s.Sum(x => x.value)
                })
                           .OrderBy(s => s.month)
                           .ToList(),
                           JsonRequestBehavior.AllowGet
                           ));
            }
        }
示例#13
0
        public ActionResult Items()
        {
            using (ClinicContext db = new ClinicContext())
            {
                var items = db.Items
                            .Select(i => new
                {
                    name  = i.Name,
                    value = i.Count
                })
                            .ToList();

                return(Json(
                           items.GroupBy(i => i.name)
                           .Select(i => new
                {
                    name = i.Key,
                    value = i.Sum(x => x.value)
                })
                           .OrderBy(i => i.name)
                           .ToList(),
                           JsonRequestBehavior.AllowGet
                           ));
            }
        }
示例#14
0
        private void DoctorsListForm_Load(object sender, EventArgs e)
        {
            clinicCtx = new ClinicContext(); //Clinic Context instantiate as global for widely use

            PopulateDoctorListBox();         // Populate the doctor name in the list box

            //Set up the list view for the fitler
            SetUpListViewHeader(TimeFilterListView, "Time");     //<-------- for TIME filter
            SetUpListViewHeader(GenderFilterListView, "Gender"); //<-------- for GENDER filter


            //Populate the time filter list view
            PopulateTimeListView();
            // Populate the gender filter list view
            PopulateGenderListView();

            // Set check for all the items in gender filter listview
            SetItemListCheck(GenderFilterListView, "check");

            // Set uncheck for all the items in gender filter listview
            SetItemListCheck(TimeFilterListView, "uncheck");

            // Collect the checked item in the filter initially when the doctor form load
            checkedGender = GetCheckFilterItem(GenderFilterListView);
            checkedTime   = GetCheckFilterItem(TimeFilterListView);

            EventHandlerToggle(true);

            ExitButton.Click += CloseForm; //Close form the exit click
        }
示例#15
0
        private List <string> SeedUsers(ClinicContext context)
        {
            List <(User user, String password)> seedUsers = new List <(User, string)>();

            seedUsers.Add(new(new User {
                UserName = "******", Email = "*****@*****.**"
            }, "GAP123!"));
            seedUsers.Add(new(new User {
                UserName = "******", Email = "*****@*****.**"
            }, "GAP123!"));
            seedUsers.Add(new(new User {
                UserName = "******", Email = "*****@*****.**"
            }, "GAP123!"));
            seedUsers.Add(new(new User {
                UserName = "******", Email = "*****@*****.**"
            }, "GAP123!"));
            seedUsers.Add(new(new User {
                UserName = "******", Email = "*****@*****.**"
            }, "GAP123!"));

            var userStore   = new UserStore <User>(context);
            var userManager = new UserManager <User>(userStore);

            foreach ((User, String)tuple in seedUsers)
            {
                userManager.Create(tuple.Item1, tuple.Item2);
            }

            context.SaveChanges();

            return(context.Users.Select(sU => sU.Id).ToList());
        }
示例#16
0
 public IdentityService(UserManager <IdentityUser> userManager, JwtSettings jwtSettings, TokenValidationParameters tokenValidationParameters, ClinicContext context, RoleManager <IdentityRole> roleManager)
 {
     _userManager = userManager;
     _jwtSettings = jwtSettings;
     _tokenValidationParameters = tokenValidationParameters;
     _context     = context;
     _roleManager = roleManager;
 }
示例#17
0
 public static void  ExecuteWithoutGuid(Action <ClinicContext> action)
 {
     using (var db = new ClinicContext())
     {
         db.Database.Connection.Open();
         action(db);
     }
 }
示例#18
0
        //public static void Execute(Action<ClinicContext> func, Guid guid)
        //{

        //    if (!ValidationService.IsValidToken(guid))
        //        throw new UnauthorizedAccessException("Доступ запрещен");
        //    using (var db = new ClinicContext())
        //    {
        //        db.Database.Connection.Open();
        //        func(db);
        //    }

        //}

        public static T ExecuteWithoutGuid <T>(Func <ClinicContext, T> func)
        {
            using (var db = new ClinicContext())
            {
                db.Database.Connection.Open();
                return(func(db));
            }
        }
 public TruncatedTreatPlan GetTreatPlan(int id)
 {
     using (ClinicContext context = ClinicContextProvider.GetContext())
     {
         var y = context.TreatPlans.Where(x => x.Id == id).Select(x => new { x, x.Disease, x.Doctor, x.Medication, x.Patient }).SingleOrDefault();
         y.x.Disease = y.Disease; y.x.Doctor = y.Doctor; y.x.Medication = y.Medication; y.x.Patient = y.Patient;
         return(truncatedTreatPlanMapper.Map(y.x));
     }
 }
示例#20
0
 public AppointmentsController(ClinicContext context)
 {
     _db          = new SQLRepository <Appointment>(context);
     _patdb       = new SQLRepository <Patient>(context);
     _docDb       = new SQLRepository <Doctor>(context);
     _diagdb      = new SQLRepository <Diagnos>(context);
     _appDiagdb   = new SQLRepository <AppliedDiagnos>(context);
     this.context = context;
 }
 public IEnumerable <TruncatedTreatPlan> GetPatientTreatPlans(int id)
 {
     using (ClinicContext context = ClinicContextProvider.GetContext())
     {
         var y = context.TreatPlans.Where(x => x.Patient_Id == id).Select(x => new { x, x.Disease, x.Doctor, x.Medication, x.Patient }).ToList();
         y.ForEach(x => { x.x.Disease = x.Disease; x.x.Doctor = x.Doctor; x.x.Medication = x.Medication; x.x.Patient = x.Patient; });
         var res = y.Select(t => truncatedTreatPlanMapper.Map(t.x));
         return(res);
     }
 }
        public AppointmentRepositoryTest()
        {
            ClinicContext context = new ClinicContext();

            this.repository = new AppointmentRepository(context);
            context.Appointments.Add(new Appointment()
            {
                Date = new DateTime(2018, 11, 11, 11, 11, 11)
            });
        }
示例#23
0
 public static T Execute <T>(Func <ClinicContext, T> func, Guid guid)
 {
     if (!ValidationService.IsValidToken(guid))
     {
         throw new UnauthorizedAccessException("Доступ запрещен");
     }
     using (var db = new ClinicContext())
     {
         db.Database.Connection.Open();
         return(func(db));
     }
 }
示例#24
0
        public override string[] GetUsersInRole(string roleName)
        {
            _db = new ClinicContext();
            var role = _db.Roles.Include(u => u.Users).FirstOrDefault(u => u.Name == roleName);

            if (role != null)
            {
                return
                    (role.Users.Select(x => x.NT).ToArray());
            }

            return(new string[] {});
        }
示例#25
0
        public override string[] GetRolesForUser(string username)
        {
            _db = new ClinicContext();
            var user = _db.Users.Include(u => u.Roles).FirstOrDefault(u => u.NT == username);

            if (user != null)
            {
                return
                    (user.Roles.Select(
                         x => x.Name).ToArray());
            }

            return(new string[] { });
        }
        private void BookAppointmentForm_Load(object sender, EventArgs e)
        {
            //create new context object when the form loads
            ctx = new ClinicContext();
            ctx.Patients.Add(newPatient);
            ctx.Doctors.Add(newDoctor);

            //turn event handler on
            BookButton.Click += CreateNewAppointment;
            ExitButton.Click += CloseForm;

            //change combobox style to make it read only
            SelectDoctorComboBox.DropDownStyle       = ComboBoxStyle.DropDownList;
            AppointmentTimeBoxcomboBox.DropDownStyle = ComboBoxStyle.DropDownList;
        }
示例#27
0
        public override bool IsUserInRole(string username, string roleName)
        {
            _db = new ClinicContext();
            var user = _db.Users.Include(u => u.Roles).FirstOrDefault(u => u.NT == username);

            if (user == null)
            {
                return(false);
            }


            return
                (user.Roles.Any(
                     x => x.Name == roleName));
        }
示例#28
0
        public void AnimalRepository_Add_NotName_Exception()
        {
            //Arrange (Preparación)
            ClinicContext        context    = new ClinicContext();
            IRepository <Animal> repository = new AnimalRepository(context);
            Animal animal = new Animal()
            {
                Id = 1
            };

            //Act (Ejecución)
            Action testCode = () => repository.Add(animal);

            //Assert (Comprobación)
            Assert.Throws <ArgumentNullException>(testCode);
        }
示例#29
0
        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            _db = new ClinicContext();
            if (string.IsNullOrEmpty(usernameToMatch))
            {
                return
                    (_db.Roles.Include(r => r.Users).Where(x => x.Name == roleName).SelectMany(
                         x => x.Users).Select(x => x.NT).
                     ToArray());
            }

            return
                (_db.Roles.Include(r => r.Users).Where(x => x.Name == roleName).SelectMany(
                     x => x.Users).Where(x => x.NT.Contains(usernameToMatch)).Select(x => x.NT).
                 ToArray());
        }
        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            //It's important to check whether session object is ready
            if (HttpContext.Current.Session == null)
            {
                return;
            }
            CultureInfo ci;

            // A retirer pour Windows Authentification
            if (Session["Language"] == null)

            {
                var db   = new ClinicContext();
                var user = db.Users.First(x => x.NT == User.Identity.Name);
                if (!string.IsNullOrEmpty(user.Language.Name))
                {
                    Session["Language"] = user.Language.Name;
                    ci = new CultureInfo(user.Language.Name);
                }
                else
                {
                    var langName = "en";

                    //Try to get values from Accept lang HTTP header
                    if (HttpContext.Current.Request.UserLanguages != null &&
                        HttpContext.Current.Request.UserLanguages.Length != 0)
                    {
                        //Gets accepted list
                        langName = HttpContext.Current.Request.UserLanguages[0].Substring(0, 2);
                    }
                    ci = new CultureInfo(langName);
                    user.Language.Name  = ci.Name;
                    Session["Language"] = ci.Name;
                }

                db.SaveChanges(User.Identity.Name);
            }
            else
            {
                ci = new CultureInfo((string)Session["Language"]);
            }

            Thread.CurrentThread.CurrentUICulture = ci;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(ci.Name);
        }