public LoginWindow(Role[] roles, ApplicationManager appMgr)
 {
     InitializeComponent();
     this.appMgr = appMgr;
     this.authRoles = roles;
     this.isRoleAuth = true;
 }
        public InventoryManager(ApplicationManager appMgr)
        {
            AppManager = appMgr;
            Inventory = new ObservableCollection<InventoryItem>();
            InventoryUsage = new ObservableCollection<InventoryItem>();

            AppManager.ApplicationDb.Inventory.ToList().ForEach(item=> Inventory.Add(item));
        }
        public PatientManager(ApplicationManager appMgr)
        {
            this.AppManager = appMgr;
            this.invManager = appMgr.InventoryManagement;
            Patients = new List<Patient>();

            Patients = AppManager.ApplicationDb.Patients.Select(m => m).ToList();
        }
        private static void PopulateEmployees(ApplicationManager appMgr)
        {
            var emps = appMgr.ApplicationDb.Employees.Select(m => m);

            appMgr.ApplicationDb.Employees.RemoveRange(emps);

            Employee pista = new Employee("pista", "1234");
            pista.Name = "Istápoló István";
            pista.Phone = "+3630111";
            pista.Salary = 250000;
            pista.Role = Role.Doctor;
            pista.DateOfBirth = "1980.05.21";

            Employee margit = new Employee("margit", "1234");
            margit.Name = "Minta Margit";
            margit.Phone = "+3630112";
            margit.Salary = 150000;
            margit.Role = Role.Nurse;
            margit.DateOfBirth = "1972.09.13";

            Employee laci = new Employee("laci", "1234");
            laci.Name = "Laboráns László";
            laci.Phone = "+3630113";
            laci.Salary = 200000;
            laci.Role = Role.Laboratorian;
            laci.DateOfBirth = "1986.01.06";

            Employee eszti = new Employee("eszti", "1234");
            eszti.Name = "Eszes Eszter";
            eszti.Phone = "+3630114";
            eszti.Salary = 180000;
            eszti.Role = Role.Administrator;
            eszti.DateOfBirth = "1981.11.26";

            Employee andris = new Employee("andris", "1234");
            andris.Name = "Adatrögzítő András";
            andris.Phone = "+3630115";
            andris.Salary = 120000;
            andris.Role = Role.DataRecorder;
            andris.DateOfBirth = "1972.10.08";

            List<Employee> empList = new List<Employee>();
            for (int i = 0; i < 80; i++)
            {
                empList.Add(new Employee("Teszt" + i, "1234", 100000 + i, Role.Doctor, "teszt" + i, "teszt" + i, "teszt" + i, "teszt" + i));
            }

            appMgr.ApplicationDb.Employees.Add(pista);
            appMgr.ApplicationDb.Employees.Add(margit);
            appMgr.ApplicationDb.Employees.Add(laci);
            appMgr.ApplicationDb.Employees.Add(eszti);
            appMgr.ApplicationDb.Employees.Add(andris);
            appMgr.ApplicationDb.Employees.AddRange(empList);

            //ha itt megakad, bump-olni kell a verziószámot, vagy kikapcsolni a populate-et!
            appMgr.ApplicationDb.SaveChanges();
        }
        public EditProceduresWindow(ApplicationManager appMgr, Ward ward)
        {
            InitializeComponent();
            AppMgr = appMgr;
            Ward = ward;
            AllProcedures = new ObservableCollection<ProcedureType>();
            ChosenProcedures = new ObservableCollection<ProcedureType>();

            var procedures = AppMgr.ApplicationDb.ProcedureTypes.ToList();
            foreach (ProcedureType procedure in procedures)
                AllProcedures.Add(procedure);
            foreach (ProcedureType procedure in ward.Procedures)
            {
                ChosenProcedures.Add(procedure);
                AllProcedures.Remove(procedure);
            }

            DataContext = this;
        }
 public LoginWindow(ApplicationManager appMgr)
 {
     InitializeComponent();
     this.appMgr = appMgr;
 }
 public EditUnitView(ApplicationManager appMgr)
 {
     unit = new Unit();
     employees = new ObservableCollection<Employee>();
     var empList = appMgr.ApplicationDb.Employees.ToList();
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            appMgr = new ApplicationManager();
            ApplicationUser = appMgr.ApplicationUser;
            DataContext = this;

            // --- TEST CODE ---
            ////Hospitalmanager-be visz auth nélkül
            //appMgr.HospitalManagement = new HospitalManager(appMgr);
            //HospitalManagementWindow HospitalManagementView = new HospitalManagementWindow(appMgr.HospitalManagement);
            //HospitalManagementView.ShowDialog();

            //Patientmanager-be visz auth nélkül
            //appMgr.PatientManagement = new Model.PatientManagement.PatientManager(appMgr);

            //majd ezt is át kell vezetni
            //appMgr.InventoryManagement = new Model.InventoryManagement.InventoryManager(appMgr);

            //PatientManagementWindow PatientManagementView = new PatientManagementWindow(appMgr.PatientManagement);
            //PatientManagementView.ShowDialog();

            // --- END OF TEST CODE ---

            DbLoadThread = new Thread(() =>
            {
                appMgr.InitializeDataBase();
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    Label_DbConnection.Content = "kapcsolódva";
                    isConnected = true;
                }));
            });

            DbLoadThread.Start();
        }
        private static void PopulatePatients(ApplicationManager appMgr)
        {
            var pats = appMgr.ApplicationDb.Patients.Select(m => m);
            appMgr.ApplicationDb.Patients.RemoveRange(pats);

            Patient kati = new Patient(
                "Kómás Kati",   //name
                "069011111",       //tel
                "1996.06.20",   //DoB
                "9991999",         //SSN
                "kamucím1",        //address
                null,           //medicalHistory
                Gender.Female   //Gender
                );
            /////
            kati.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure proc = new Model.PatientManagement.Procedure();
            //proc.Name = "Új eljárás kati";
            kati.MedicalHistory[0].NewProcedure(proc);

            Patient karesz = new Patient(
                "Kankós Karesz",   //name
                "0660222222",       //tel
                "1991.02.13",   //DoB
                "1359143",         //SSN
                 "kamucím2",        //address
                null,           //medicalHistory
                Gender.Male   //Gender
                );
            karesz.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure prockaresz = new Model.PatientManagement.Procedure();
            //prockaresz.Name = "Új eljárás karesz";
            karesz.MedicalHistory[0].NewProcedure(prockaresz);

            Patient imre = new Patient(
                "Itókás Imre",   //name
                "0670333333",       //tel
                "1978.09.06",   //DoB
                "9083825",         //SSN
                "kamucím3",        //address
                null,           //medicalHistory
                Gender.Male   //Gender
                );
            imre.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure procimre = new Model.PatientManagement.Procedure();
            //procimre.Name = "Új eljárás imre";
            imre.MedicalHistory[0].NewProcedure(procimre);

            Patient hilda = new Patient(
                "Hasmenős Hilda",   //name
                "062044444",        //tel
                "1957.11.12",       //DoB
                "1125267",            //SSN
                "kamucím3",         //address
                null,               //medicalHistory
                Gender.Female       //Gender
                );
            hilda.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure prochilda = new Model.PatientManagement.Procedure();
            //prochilda.Name = "Új eljárás hilda";
            hilda.MedicalHistory[0].NewProcedure(prochilda);

            Patient bertold = new Patient(
                "Barangoló Bertold",//name
                "064055555",        //tel
                "1985.02.16",       //DoB
                "9306484",            //SSN
                "kamucím4",         //address
                null,               //medicalHistory
                Gender.Male         //Gender
                );
            bertold.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure procbertold = new Model.PatientManagement.Procedure();
            //procbertold.Name = "Új eljárás bertold";
            bertold.MedicalHistory[0].NewProcedure(procbertold);

            //List<Patient> patList = new List<Patient>();
            //for (int i = 0; i < 81; i++)
            //{
            //    patList.Add(new Patient("Teszt" + i, "0660" + i, "1980.XX." + i,
            //        9989110 + i, i + ". utca " + 10 * i, null, (Gender)(i % 2)));
            //}

            appMgr.ApplicationDb.Patients.Add(kati);
            appMgr.ApplicationDb.Patients.Add(karesz);
            appMgr.ApplicationDb.Patients.Add(imre);
            appMgr.ApplicationDb.Patients.Add(hilda);
            appMgr.ApplicationDb.Patients.Add(bertold);

            //appMgr.ApplicationDb.Patients.AddRange(patList);

            //Console.WriteLine("kati medicalhistory timestamp: "+ kati.MedicalHistory[0].CreatedTimestamp);
            //Console.WriteLine("kati medicalhistory0_procedure0 timestamp: " + kati.MedicalHistory[0].Procedures[0].CreatedTimestamp);

            appMgr.ApplicationDb.SaveChanges();
        }
 public static void Populate(ApplicationManager appMgr)
 {
     PopulateDb.PopulateEmployees(appMgr);
     PopulateDb.PopulateUnits(appMgr);
     PopulateDb.PopulatePatients(appMgr);
 }
        private static void PopulateUnits(ApplicationManager appMgr)
        {
            Employee hospMgr = null;

            var hosps = appMgr.ApplicationDb.Hospital.Select(m => m);
            foreach (Hospital hosp in hosps)
            {
                hosp.Departments = new List<Department>();
            }
            var wards = appMgr.ApplicationDb.Wards.Select(w => w);
            appMgr.ApplicationDb.Wards.RemoveRange(wards);
            var depts = appMgr.ApplicationDb.Departments.Select(d => d);
            appMgr.ApplicationDb.Departments.RemoveRange(depts);

            appMgr.ApplicationDb.Hospital.RemoveRange(hosps);

            var emps = appMgr.ApplicationDb.Employees.Select(m => m).ToList();
            Hospital hospital = new Hospital();
            hospital.Address = "1234 Budapest, Gyógyító köz 1.";
            foreach (Employee emp in emps)
            {
                if ("eszti".Equals(emp.Username))
                {
                    hospMgr = emp;
                }
            }

            hospital.Manager = hospMgr;
            hospital.Name = "Hubasky Magánkórház";
            hospital.Employees = emps;

            Department patientTreatDept = new Department();
            patientTreatDept.Name = "Betegellátási főosztály";
            hospital.Departments.Add(patientTreatDept);
            //appMgr.ApplicationDb.Departments.Add(patientTreatDept);

            Department surgeryDept = new Department();
            surgeryDept.Name = "Sebészeti főosztály";
            hospital.Departments.Add(surgeryDept);
            //appMgr.ApplicationDb.Departments.Add(surgeryDept);

            Department testDept = new Department();
            testDept.Name = "Teszt főosztály";
            hospital.Departments.Add(testDept);
            //appMgr.ApplicationDb.Departments.Add(test);

            List<Department> deptList = new List<Department>();
            deptList.Add(patientTreatDept);
            deptList.Add(surgeryDept);
            deptList.Add(testDept);
            appMgr.ApplicationDb.Departments.AddRange(deptList);

            XmlReader xmlReader = new XmlReader();
            int length = xmlReader.Wards.Count();
            List<Ward> wardList = new List<Ward>();
            List<Employee> empList = new List<Employee>();

            for (int i = 0; i < length-1; i++)
            {
                //wardList.Add(new Ward(i, xmlReader.Wards.ElementAt(i),
                //    emps[i % 5], emps.Where(x => x.Username.Equals("Teszt" + i)).ToList(),
                //    xmlReader.Procedures));
            }

            appMgr.ApplicationDb.Wards.Union(wardList);
            patientTreatDept.Wards.AddRange(wardList.GetRange(0, 8));
            surgeryDept.Wards.AddRange(wardList.GetRange(8, 8));
            testDept.Wards.AddRange(wardList.GetRange(16, 8));

            /*Ward walkInPatientWard = new Ward();
            walkInPatientWard.Name = "Járóbetegellátás";
            walkInPatientWard.Manager = emps[0];
            walkInPatientWard.Employees = emps;
            appMgr.ApplicationDb.Wards.Add(walkInPatientWard);

            Ward cardiologyWard = new Ward();
            cardiologyWard.Name = "Kardiológia";
            cardiologyWard.Manager = emps[1];
            appMgr.ApplicationDb.Wards.Add(cardiologyWard);*/

            /*patientTreatDept.Wards.Add(walkInPatientWard);
            patientTreatDept.Wards.Add(cardiologyWard);*/

            appMgr.ApplicationDb.Hospital.Add(hospital);

            appMgr.ApplicationDb.SaveChanges();
        }