示例#1
0
 private void buttonAddIllness_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "")
     {
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             Illness temp = new Illness {
                 Name = comboBox1.Text, Hash = comboBox1.Text.GetHashCode()
             };
             thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);
             if (!db.IllnessSet.Find(temp.Hash).Patient.Contains(thisPatient))
             {
                 if (db.IllnessSet.Find(comboBox1.Text.GetHashCode()) != null)
                 {
                     thisPatient.Illness.Add(db.IllnessSet.Find(comboBox1.Text.GetHashCode()));
                 }
                 else
                 {
                     temp.Patient.Add(thisPatient);
                     db.IllnessSet.Add(temp);
                 }
                 db.SaveChanges();
                 dataGWIllness.Rows.Add(comboBox1.Text);
                 if (!comboBox1.Items.Contains(comboBox1.Text))
                 {
                     comboBox1.Items.Add(comboBox1.Text);
                 }
             }
             else
             {
                 MessageBox.Show("Данная болезнь уже есть у данного человека");
             }
         }
     }
     else
     {
         MessageBox.Show("Выберите болезнь из известных или добавьте новую");
     }
 }
示例#2
0
文件: MenuForm.cs 项目: Iskusnik/Med
        private void MenuForm_Load(object sender, EventArgs e)
        {
            //ControlFunctions.AnalyseVisits("11111");
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                int doctorsCount = (from doctor in db.PersonSet where (doctor is Doctor)select(doctor as Doctor)).Count();
                if (doctorsCount == 0)
                {
                    Doctor newDoctor = new Doctor();
                    newDoctor.FullName         = "Администратор";
                    newDoctor.Gender           = "Администратор";
                    newDoctor.BirthDate        = new DateTime(2000, 1, 1);
                    newDoctor.Nationality      = "Администратор";
                    newDoctor.LiveAdress       = "Администратор";
                    newDoctor.RegAdress        = "Администратор";
                    newDoctor.RegDate          = new DateTime(2000, 1, 1);;
                    newDoctor.InsuranceBillNum = "Администратор";
                    newDoctor.Education        = "Администратор";
                    newDoctor.Job         = "Главврач";
                    newDoctor.Memberships = "Администратор";
                    newDoctor.BirthPlace  = "Администратор";

                    newDoctor.Documents = new Documents {
                        DocumentName = "Паспорт", DocumentNum = -1, Person = newDoctor
                    };
                    newDoctor.WorkTimes    = new List <WorkTime>();
                    newDoctor.FreeTimes    = new List <FreeTime>();
                    newDoctor.DoctorRecord = new List <DoctorRecord>();
                    newDoctor.Password     = "******";
                    newDoctor.NameHashID   = newDoctor.FullName.GetHashCode();

                    db.PersonSet.Add(newDoctor);
                    db.SaveChanges();
                }
            }
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                int patientCount = (from patient in db.PersonSet where (patient is Patient && patient.FullName == "Пациент")select(patient as Patient)).Count();
                if (patientCount == 0)
                {
                    Patient newPatient = new Patient();
                    newPatient.FullName              = "Пациент";
                    newPatient.Gender                = "Пациент";
                    newPatient.BirthDate             = new DateTime(2000, 1, 1);
                    newPatient.Nationality           = "Пациент";
                    newPatient.LiveAdress            = "Пациент";
                    newPatient.RegAdress             = "Пациент";
                    newPatient.RegDate               = new DateTime(2000, 1, 1);
                    newPatient.InsuranceBillNum      = "Пациент";
                    newPatient.BloodType             = 255;
                    newPatient.Rhesus                = "Пациент";
                    newPatient.WorkIncapacityListNum = "Пациент";
                    newPatient.InsurancePolicyNum    = "Пациент";
                    newPatient.BirthPlace            = "Пациент";


                    newPatient.Password = "******";

                    newPatient.Documents = new Documents {
                        DocumentName = "Паспорт", DocumentNum = -2, Person = newPatient
                    };
                    newPatient.MedCard = new MedCard();
                    Illness ill = new Illness {
                        Name = "Пациент"
                    };
                    ill.Hash = ill.Name.GetHashCode();
                    if (db.IllnessSet.Find(ill.Hash) != null)
                    {
                        ill = db.IllnessSet.Find(ill.Hash);
                    }
                    ill.Patient.Add(newPatient);
                    newPatient.Illness.Add(ill);

                    newPatient.NameHashID = newPatient.FullName.GetHashCode();

                    db.PersonSet.Add(newPatient);
                    //db.IllnessSet.Add(newPatient.Illness.First());
                    //db.IllnessSet.Find(newPatient.Illness.First().Hash).Patient.Add(newPatient);
                    //newPatient.Illness.Add(new Illness { Cured = true, Name = "Пациент", Hash = Name.GetHashCode()});

                    db.SaveChanges();
                }
            }


            //ControlFunctions.GenerateRandomDataBase();
        }
示例#3
0
        public static void GenerateRandomDataBase(int N = 50)
        {
            int doctorNum = random.Next(1, N / 5 + 2);

            string[] Vacancies = { "Главврач", "Хирург", "Эндокринолог", "Невролог", "Участковый врач", "Окуляринголог", "Дантист" };
            string[] NamesM    = { "Иван", "Денис", "Вячеслав", "Владимир", "Константин", "Александр", "Михаил", "Игнат", "Артём" };
            string[] NamesW    = { "Алёна", "Арина", "Елизавета", "Екатерина", "Александра", "Кристина", "Татьяна", "Людмила" };
            string[] Genders   = { "Мужской", "Женский" };
            string[] Surnames  = { "Иванов", "Александров", "Степанов", "Семёнов", "Удальцов", "Молодцов", "Бобров", "Медведев" };

            string[] BirthPlaces   = { "Уфа", "Барнаул", "Екатеринбург", "Йошкар-Ола", "Таганрог", "Егоров", "Москва", "Евпатория", "Новороссийск", "Якутск" };
            string[] DocumentTypes =
            {
                "Паспорт гражданина РФ",
                "Свидетельство о рождении",
                "Дипломатический паспорт",
                "Паспорт моряка",
                "Военный билет",
                "Удостоверение личности военнослужащего",
                "Удостоверение беженца",
                "Служебное удостоверение работника прокуратуры"
            };

            string[] Nationalities = { "Российская Федерация", "Англия", "Бавария", "Российская Федерация" };

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

            for (int i = 0; i < N; i++)
            {
                using (ModelMedDBContainer db = new ModelMedDBContainer())
                {
                    Person temp = new Person();
                    temp.BirthPlace = BirthPlaces[random.Next(0, 10)];
                    temp.BirthDate  = new DateTime(random.Next(1950, 2018), random.Next(1, 13), random.Next(1, 28));
                    temp.RegDate    = new DateTime(random.Next(1950, 2018), random.Next(1, 13), random.Next(1, 28));
                    temp.Documents  = new Documents {
                        DocumentName = DocumentTypes[random.Next(0, 8)], DocumentNum = random.Next(0, Int32.MaxValue), 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.InsuranceBillNum = random.Next(0, Int32.MaxValue).ToString();
                    temp.LiveAdress       = random.Next(0, 4).ToString();
                    temp.RegAdress        = random.Next(10, 20).ToString();
                    temp.NameHashID       = temp.FullName.GetHashCode();

                    if (temp.Documents.DocumentName == "Удостоверение беженца")
                    {
                        temp.Nationality = Nationalities[random.Next(1, 4)];
                    }
                    else
                    {
                        temp.Nationality = Nationalities[0];
                    }

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

                    if (doctorNum > 0)
                    {
                        doctorNum--;

                        Doctor t = new Doctor();
                        (t as Person).BirthDate        = temp.BirthDate;
                        (t as Person).Documents        = temp.Documents;
                        (t as Person).Documents.Person = t;
                        (t as Person).FullName         = temp.FullName;
                        (t as Person).Gender           = temp.Gender;
                        (t as Person).InsuranceBillNum = temp.InsuranceBillNum;
                        (t as Person).LiveAdress       = temp.LiveAdress;
                        (t as Person).NameHashID       = temp.NameHashID;
                        (t as Person).Nationality      = temp.Nationality;
                        (t as Person).Password         = temp.Password;
                        (t as Person).RegAdress        = temp.RegAdress;
                        (t as Person).RegDate          = temp.RegDate;
                        (t as Person).BirthPlace       = temp.BirthPlace;

                        t.Memberships = "";
                        if (0 == random.Next(0, 6))
                        {
                            t.Memberships = "Médecins Sans Frontières";
                        }
                        t.Education = Educations[random.Next(0, 3)];
                        t.Job       = Vacancies[random.Next(0, 7)];

                        int week = random.Next(0, 4);
                        if (0 == week)
                        {
                            t.FreeTimes = makeJob(new int[] { 0, 3, 5 }, DateTime.Today, t, random.Next(3, 8), random.Next(5, 10), random.Next(10, 20));
                        }
                        if (1 == week)
                        {
                            t.FreeTimes = makeJob(new int[] { 0, 1, 2, 5 }, DateTime.Today, t, random.Next(3, 8), random.Next(5, 10), random.Next(10, 20));
                        }
                        if (2 == week)
                        {
                            t.FreeTimes = makeJob(new int[] { 0, 1, 2, 3, 4, 5, 6 }, DateTime.Today, t, random.Next(3, 8), random.Next(5, 10), random.Next(10, 20));
                        }
                        if (3 == week)
                        {
                            t.FreeTimes = makeJob(new int[] { 4 }, DateTime.Today, t, random.Next(3, 8), random.Next(5, 10), random.Next(10, 20));
                        }

                        t.WorkTimes    = new List <WorkTime>();
                        t.DoctorRecord = new List <DoctorRecord>();
                        db.PersonSet.Add(t);
                        db.SaveChanges();
                    }
                    else
                    {
                        Patient t = new Patient();
                        (t as Person).BirthDate        = temp.BirthDate;
                        (t as Person).Documents        = temp.Documents;
                        (t as Person).FullName         = temp.FullName;
                        (t as Person).Gender           = temp.Gender;
                        (t as Person).InsuranceBillNum = temp.InsuranceBillNum;
                        (t as Person).LiveAdress       = temp.LiveAdress;
                        (t as Person).NameHashID       = temp.NameHashID;
                        (t as Person).Nationality      = temp.Nationality;
                        (t as Person).Password         = temp.Password;
                        (t as Person).RegAdress        = temp.RegAdress;
                        (t as Person).RegDate          = temp.RegDate;
                        (t as Person).Documents.Person = t;
                        (t as Person).BirthPlace       = temp.BirthPlace;

                        t.BloodType = (byte)random.Next(1, 5);
                        t.Rhesus    = "+";
                        if (random.Next(0, 100) < 50)
                        {
                            t.Rhesus = "-";
                        }
                        t.WorkIncapacityListNum = random.Next(0, int.MaxValue).ToString();
                        t.InsurancePolicyNum    = random.Next(0, int.MaxValue).ToString();
                        for (int j = 0; j < random.Next(0, 4); j++)
                        {
                            Illness ill = new Illness {
                                Name = random.Next(0, 100).ToString()
                            };
                            ill.Hash = ill.Name.GetHashCode();
                            if (db.IllnessSet.Find(ill.Hash) != null)
                            {
                                ill = db.IllnessSet.Find(ill.Hash);
                            }
                            ill.Patient.Add(t);
                            t.Illness.Add(ill);
                        }
                        t.MedCard         = new MedCard();
                        t.MedCard.Patient = t;
                        for (int j = 0; j < random.Next(0, 3); j++)
                        {
                            int      r      = random.Next(0, db.FreeTimeSet.Count());
                            FreeTime freeTi = db.FreeTimeSet.ToArray()[r];
                            //FreeTime freeTi = db.FreeTimeSet.Local.ToArray()[r];
                            //Doctor tempDoctor = (Doctor)(from docs in db.PersonSet.Local where (docs.BirthDate == freeTi.Doctor.BirthDate && docs.NameHashID == freeTi.Doctor.NameHashID) select docs).ToList()[0];

                            Doctor tempDoctor = (Doctor)db.PersonSet.Find(freeTi.Doctor.BirthDate, freeTi.Doctor.NameHashID);

                            WorkTime workTi = new WorkTime {
                                Start = freeTi.Start, Doctor = tempDoctor, Finish = freeTi.Finish, BirthDate = tempDoctor.BirthDate, NameHashID = tempDoctor.NameHashID
                            };

                            db.FreeTimeSet.Remove(freeTi);

                            workTi.VisitInfo = new VisitInfo
                            {
                                WorkTimes        = workTi,
                                DateStart        = workTi.Start,
                                DateFinish       = workTi.Finish,
                                DoctorID         = tempDoctor.NameHashID,
                                Patient          = t,
                                PatientBirthDate = t.BirthDate,
                                PatientFullName  = t.FullName
                            };
                            t.VisitInfo.Add(workTi.VisitInfo);
                            tempDoctor.WorkTimes.Add(workTi);
                            db.WorkTimeSet.Add(workTi);
                            db.VisitInfoSet.Add(workTi.VisitInfo);
                        }
                        db.PersonSet.Add(t);

                        db.SaveChanges();
                    }
                }
            }
        }