Exemplo n.º 1
0
        static public void RemoveVisit(int id)
        {
            TimeForVisit visit = dbContext.TimeForVisitSet.Find(id);

            dbContext.TimeForVisitSet.Remove(visit);
            dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        static public TimeForVisit CreateTimeForVisit(string docInfo,
                                                      string corpusName,
                                                      string cabinetNum,
                                                      string date,
                                                      string time)
        {
            TimeForVisit timeForVisit = new TimeForVisit();



            string[] docFIODB = docInfo.Split('_');
            string   docFIO   = docFIODB[0];
            DateTime docDB    = DateTime.Parse(docFIODB[1]);
            Doctor   doctor   = (Doctor)(from pers in dbContext.PersonSet where pers is Doctor && pers.FullName == docFIO && pers.BirthDate == docDB select pers).ToList()[0];



            Corpus  corpus  = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToArray()[0];
            int     num     = int.Parse(cabinetNum);
            Cabinet cabinet = (from c in corpus.Cabinet where c.Num == num select c).ToArray()[0];


            DateTime dateValue = DateTime.Parse(date);
            DateTime timeValue = DateTime.Parse(time);
            DateTime visitTime = dateValue.Add(timeValue.TimeOfDay);



            timeForVisit.Cabinet   = cabinet;
            timeForVisit.Doctor    = doctor;
            timeForVisit.VisitTime = visitTime;

            return(timeForVisit);
        }
Exemplo n.º 3
0
 static public string AddTimeForVisitToPatient(Patient patient, TimeForVisit visit)
 {
     visit         = dbContext.TimeForVisitSet.Find(visit.Id);
     patient       = (Patient)dbContext.PersonSet.Find(patient.Id);
     visit.Patient = patient;
     patient.TimeForVisit.Add(visit);
     dbContext.SaveChanges();
     return(null);
 }
Exemplo n.º 4
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedCells.Count != 0)
     {
         int          id        = (int)dataGridView1.SelectedCells[3].Value;
         TimeForVisit visit     = db.TimeForVisitSet.Find(id);
         Form         editVisit = new EditVisit(visit);
         editVisit.ShowDialog();
         LoadData(db.TimeForVisitSet.ToList());
     }
     else
     {
         MessageBox.Show("Выберите приём для редактирования");
     }
 }
Exemplo n.º 5
0
        static public TimeForVisit EditVisit(TimeForVisit visit,
                                             string docInfo,
                                             string patInfo,
                                             string corpusName,
                                             string cabinetNum,
                                             string date,
                                             string time)
        {
            visit = dbContext.TimeForVisitSet.Find(visit.Id);



            string[] docFIODB = docInfo.Split('_');
            string   docFIO   = docFIODB[0];
            DateTime docDB    = DateTime.Parse(docFIODB[1]);
            Doctor   doctor   = (Doctor)(from pers in dbContext.PersonSet where pers is Doctor && pers.FullName == docFIO && pers.BirthDate == docDB select pers).ToList()[0];


            Patient patient = null;

            if (patInfo != "Нет пациента" && patInfo != "")
            {
                string[] patFIODB = patInfo.Split('_');
                string   patFIO   = patFIODB[0];
                DateTime patDB    = DateTime.Parse(patFIODB[1]);
                patient = (Patient)(from pers in dbContext.PersonSet where pers is Patient && pers.FullName == patFIO && pers.BirthDate == patDB select pers).ToList()[0];
            }


            Corpus  corpus  = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToArray()[0];
            int     num     = int.Parse(cabinetNum);
            Cabinet cabinet = (from c in corpus.Cabinet where c.Num == num select c).ToArray()[0];


            DateTime dateValue = DateTime.Parse(date);
            DateTime timeValue = DateTime.Parse(time);
            DateTime visitTime = dateValue.Add(timeValue.TimeOfDay);

            visit.Cabinet   = cabinet;
            visit.Doctor    = doctor;
            visit.Patient   = patient;
            visit.VisitTime = visitTime;

            dbContext.Entry(visit).State = System.Data.Entity.EntityState.Modified;
            dbContext.SaveChanges();

            return(visit);
        }
Exemplo n.º 6
0
        private void buttonRemoveDocFromJob_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0 || dataGridView1.SelectedCells[0].Value == null)
            {
                MessageBox.Show("Выберите приём", "Ошибка");
            }
            else
            {
                int          id    = (int)dataGridView1.SelectedCells[3].Value;
                TimeForVisit visit = (TimeForVisit)db.TimeForVisitSet.Find(id);

                Form editVisit = new EditVisit(visit);
                editVisit.ShowDialog();
                ReloadForm(true);
            }
            ReloadForm();
        }
Exemplo n.º 7
0
        static public string AddTimeForVisit(TimeForVisit timeForVisit)
        {
            //Проверка не прошло ли время, в которое хотят поставить время для приёмов
            if (timeForVisit.VisitTime < DateTime.Today)
            {
                return(String.Format("Нельзя назначить приём в указанную дату. Сегодня уже {0}", DateTime.Today));
            }
            else
            {
                ;
            }

            //Проверка наличия совпадений по врачу
            var searchResult = (from t in dbContext.TimeForVisitSet
                                where t.VisitTime == timeForVisit.VisitTime &&
                                t.Doctor.Id == timeForVisit.Doctor.Id
                                select t).ToList();

            if (searchResult.Count != 0)
            {
                return("Такое время у такого врача уже занято");
            }
            else
            {
                ;
            }

            //Проверка кабинета
            searchResult = (from t in dbContext.TimeForVisitSet
                            where t.VisitTime == timeForVisit.VisitTime &&
                            t.Cabinet.Id == timeForVisit.Cabinet.Id
                            select t).ToList();
            if (searchResult.Count != 0)
            {
                return("Кабинет занят в это время");
            }

            //Добавление в БД
            dbContext.TimeForVisitSet.Add(timeForVisit);
            dbContext.SaveChanges();
            return(null);
        }
Exemplo n.º 8
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (comboBoxCabinet.SelectedIndex >= 0 &&
         comboBoxCorpus.SelectedIndex >= 0 &&
         comboBoxDoctor.SelectedIndex >= 0)
     {
         TimeForVisit tfv    = ControlFunctions.CreateTimeForVisit(comboBoxDoctor.Text, comboBoxCorpus.Text, comboBoxCabinet.Text, datePicker.Text, timePicker.Text);
         string       result = ControlFunctions.AddTimeForVisit(tfv);
         if (result != null)
         {
             MessageBox.Show(result);
         }
         else
         {
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Заполните поля");
     }
 }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBoxTime.Text == "")
            {
                MessageBox.Show("Выберите специальность, врача, день и время");
            }
            else
            {
                Doctor   tempDoctor    = (Doctor)db.PersonSet.Find(DoctorsList[index].Id);
                DateTime visitDateTime = DateTime.Parse(comboBoxDate.Text);

                visitDateTime = visitDateTime.Add(TimeSpan.FromTicks(DateTime.Parse(comboBoxTime.Text).TimeOfDay.Ticks));


                TimeForVisit visit = (from time in db.TimeForVisitSet
                                      where time.Doctor.Id == tempDoctor.Id &&
                                      time.VisitTime == visitDateTime
                                      select time).ToArray()[0];

                comboBoxTime.Items.Remove(comboBoxTime.Text);



                ControlFunctions.AddTimeForVisitToPatient(patient, visit);

                db.SaveChanges();
                MessageBox.Show("Запись совершена");
                button1.Enabled = false;

                var timeForVisit = (from t in db.TimeForVisitSet
                                    where t.Patient == null
                                    select t).ToList();
                if (timeForVisit.Count == 0)
                {
                    MessageBox.Show("Свободных для записи врачей нет");
                    Close();
                }
            }
        }
Exemplo n.º 10
0
        protected override void Seed(ModelMedContainer db)
        {
            Job jobNull = ControlFunctions.CreateJob("Нет должности");

            db.JobSet.Add(jobNull);
            Job jobA = ControlFunctions.CreateJob("Главврач");

            db.JobSet.Add(jobA);
            Job jobB = ControlFunctions.CreateJob("Терапевт");

            db.JobSet.Add(jobB);
            db.SaveChanges();

            Doctor docA = ControlFunctions.CreateDoctor("Александров Александр Иванович", DateTime.Parse("11.11.1990"), "Паспорт РФ", "0000000001", "Главврач", "Home,1", "Enough", "Мужской", "12345", "2");

            db.PersonSet.Add(docA);


            Doctor docB = ControlFunctions.CreateDoctor("Иванов Иван Иванович", DateTime.Parse("11.11.1980"), "Паспорт РФ", "0000000002", "Терапевт", "Home,2", "Enough", "Мужской", "12346", "2");

            db.PersonSet.Add(docB);


            db.SaveChanges();



            Doctor docC = ControlFunctions.CreateDoctor("Иванов Иван Иванович", DateTime.Parse("11.11.1955"), "Паспорт РФ", "0000000003", "Терапевт", "Home,2", "Enough", "Мужской", "123473", "2");

            ControlFunctions.AddPerson(docC);



            Patient patA  = ControlFunctions.CreatePatient("Иванов Иван Иванович", DateTime.Parse("11.12.1980"), "Паспорт РФ", "0000000004", "Home,3", "+1", "Мужской", "12347", "2");
            Corpus  corpA = ControlFunctions.CreateCorpus(3, "Корпус 1");

            db.CorpusSet.Add(corpA);
            db.SaveChanges();
            Cabinet cabA = ControlFunctions.CreateCabinet("Корпус 1", 1, 1);

            db.CabinetSet.Add(cabA);
            db.SaveChanges();

            TimeForVisit timeA = ControlFunctions.CreateTimeForVisit("Иванов Иван Иванович_11.11.1980", "Корпус 1", "1", "11.11.2000", "00:00:00");
            TimeForVisit timeB = ControlFunctions.CreateTimeForVisit("Иванов Иван Иванович_11.11.1980", "Корпус 1", "1", "11.11.2000", "12:13:17");

            db.TimeForVisitSet.Add(timeB);
            db.TimeForVisitSet.Add(timeA);
            patA.TimeForVisit.Add(timeA);
            timeA.Patient = patA;


            Illness illA  = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь А");
            Illness illAA = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь А");
            Illness illB  = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь Б");

            db.IllnessSet.Add(illA);
            illA.MedCard.Add(patA.MedCard);
            patA.MedCard.Illness.Add(illA);

            db.IllnessSet.Add(illB);
            illB.MedCard.Add(patA.MedCard);
            patA.MedCard.Illness.Add(illB);


            db.PersonSet.Add(patA);



            Record recA = ControlFunctions.CreateRecord(DateTime.Now, docB, "111", patA.MedCard);
            Record recB = ControlFunctions.CreateRecord(DateTime.Parse("11.11.2000"), docB, "222", patA.MedCard);
            Record recC = ControlFunctions.CreateRecord(DateTime.Parse("11.11.2010"), docA, "333", patA.MedCard);

            db.RecordSet.Add(recA);
            db.RecordSet.Add(recB);
            db.RecordSet.Add(recC);

            db.JobSet.Add(ControlFunctions.CreateJob("testJob"));
            db.SaveChanges();
        }
Exemplo n.º 11
0
        public static void GenerateRandomDataBase(int N = 100)
        {
            int doctorNum = random.Next(1, N / 5 + 2);

            string[] jobs      = { "Главврач", "Хирург", "Эндокринолог", "Невролог", "Участковый врач", "Окуляринголог", "Дантист" };
            string[] corpuses  = { "1", "2", "3" };
            string[] illnesses = { "Болезнь В", "Болезнь Г", "Болезнь Д", "Болезнь Е", "Болезнь Ж" };
            foreach (string job in jobs)
            {
                AddJob(CreateJob(job));
            }

            foreach (string corpus in corpuses)
            {
                AddCorpus(CreateCorpus(3, corpus));
            }

            foreach (string illness in illnesses)
            {
                AddIllness(CreateIllness("Описание" + " " + random.Next(0, 10).ToString(), illness));
            }

            foreach (Corpus c in dbContext.CorpusSet)
            {
                for (int i = 1; i <= 10; i++)
                {
                    dbContext.CabinetSet.Add(CreateCabinet(c.Name, random.Next(1, 4), i));
                }
            }

            dbContext.SaveChanges();



            string[] namesM   = { "Иван", "Денис", "Вячеслав", "Владимир", "Константин", "Александр", "Михаил", "Игнат", "Артём" };
            string[] namesW   = { "Алёна", "Арина", "Елизавета", "Екатерина", "Александра", "Кристина", "Татьяна", "Людмила" };
            string[] genders  = { "Мужской", "Женский" };
            string[] surnames = { "Иванов", "Александров", "Степанов", "Семёнов", "Удальцов", "Молодцов", "Бобров", "Медведев" };

            string[] adresses      = { "Пермская", "Кирова", "Революции", "Совесткая", "Полевая", "Парковая", "Морская", "Веселая" };
            string[] documentTypes =
            {
                "Паспорт гражданина РФ",
                "Свидетельство о рождении",
                "Дипломатический паспорт",
                "Военный билет",
                "Служебное удостоверение работника прокуратуры"
            };


            string[] educations = { "Мед.образование1", "Мед.образование2", "Мед.образование3" };

            for (int i = 0; i < N; i++)
            {
                Person temp = new Person();
                temp.Adress    = adresses[random.Next(0, 8)] + " " + random.Next(1, 20).ToString() + "," + " " + random.Next(1, 50).ToString();
                temp.BirthDate = new DateTime(random.Next(1950, 2018), random.Next(1, 13), random.Next(1, 28));
                temp.Document  = new Document {
                    Type = documentTypes[random.Next(0, 5)], Num = random.Next(0, Int32.MaxValue).ToString(), Person = temp
                };
                if (random.Next(0, 2) == 0)
                {
                    temp.Gender   = genders[0];
                    temp.FullName = surnames[random.Next(0, 8)] + " " + namesM[random.Next(0, 9)] + " " + namesM[random.Next(0, 9)] + "ович";
                }
                else
                {
                    temp.Gender   = genders[1];
                    temp.FullName = surnames[random.Next(0, 8)] + "а " + namesW[random.Next(0, 8)] + " " + namesM[random.Next(0, 9)] + "овна";
                }
                temp.InsuranceNum = random.Next(0, Int32.MaxValue).ToString();


                temp.Password = "******";

                if (doctorNum > 0)
                {
                    doctorNum--;
                    Doctor t = CreateDoctor(temp.FullName, temp.BirthDate, temp.Document.Type, temp.Document.Num, jobs[random.Next(0, 7)], temp.Adress, educations[random.Next(0, 3)], temp.Gender, temp.InsuranceNum, temp.Password);
                    dbContext.PersonSet.Add(t);
                    dbContext.SaveChanges();
                }
                else
                {
                    int    num = (byte)random.Next(1, 5);
                    string res = "+";
                    if (random.Next(0, 100) < 50)
                    {
                        res = "-";
                    }
                    Patient t = CreatePatient(temp.FullName, temp.BirthDate, temp.Document.Type, temp.Document.Num, temp.Adress, res + num.ToString(), temp.Gender, temp.InsuranceNum, temp.Password);



                    dbContext.PersonSet.Add(t);



                    for (int k = 0; k < 10; k++)
                    {
                        Person[] doctors   = (from d in dbContext.PersonSet where d is Doctor select d).ToArray();
                        int      randomDoc = random.Next(0, doctors.Length);

                        string docInfo = doctors[randomDoc].FullName + "_" + doctors[randomDoc].BirthDate.ToShortDateString();

                        string   date = (new DateTime(random.Next(1950, 2018), random.Next(1, 13), random.Next(1, 28))).ToShortDateString();
                        DateTime time = DateTime.Today + TimeSpan.FromDays(random.Next(1, 15));
                        time += DateTime.Now.TimeOfDay + TimeSpan.FromHours(random.Next(0, 23)) + TimeSpan.FromMinutes(random.Next(0, 2) * 30);

                        TimeForVisit tfv = CreateTimeForVisit(docInfo, corpuses[random.Next(0, corpuses.Length)], random.Next(1, 11).ToString(), time.ToShortDateString(), time.ToShortTimeString());
                        tfv.Patient = t;

                        AddTimeForVisit(tfv);
                    }

                    for (int k = 0; k < random.Next(5, 12); k++)
                    {
                        Illness[] ill = (from illlnesss in dbContext.IllnessSet select illlnesss).ToArray();
                        t.MedCard.Illness.Add(ill[random.Next(0, ill.Length)]);
                    }

                    for (int k = 0; k < random.Next(2, 7); k++)
                    {
                        Person[] doctors   = (from d in dbContext.PersonSet where d is Doctor select d).ToArray();
                        int      randomDoc = random.Next(0, doctors.Length);

                        AddRecord(CreateRecord(DateTime.Today + TimeSpan.FromMinutes(random.Next(0, 60)), (Doctor)doctors[randomDoc], "Запись" + " " + k.ToString(), t.MedCard));
                    }


                    dbContext.SaveChanges();
                }
            }
        }
Exemplo n.º 12
0
        public EditVisit(TimeForVisit visit)
        {
            this.visit = visit;

            InitializeComponent();
        }