示例#1
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != null && comboBox1.Text != "")
     {
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             Head = (Doctor)db.PersonSet.Find(Head.BirthDate, Head.NameHashID);
             if (MessageBox.Show("Изменение расписания приведёт к удалению всех грядущих приёмов пациентов для этого врача. Продолжить?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.OK)
             {
                 long     nameID = docs[comboBox1.SelectedIndex].NameHashID;
                 DateTime date   = docs[comboBox1.SelectedIndex].BirthDate;
                 Doctor   t      = (Doctor)db.PersonSet.Find(date, nameID);
                 db.FreeTimeSet.RemoveRange(t.FreeTimes);
                 t.FreeTimes.Clear();
                 bool[] weekCheck = { checkBox1.Checked, checkBox2.Checked, checkBox3.Checked, checkBox4.Checked, checkBox5.Checked, checkBox6.Checked, checkBox7.Checked };
                 t.FreeTimes = ControlFunctions.makeJob(weekCheck, dateTimePicker1.Value, t, (int)numericUpDownPeriod.Value, (int)numericUpDownHours.Value, (int)numericUpDownDays.Value);
                 var workTime = (from workT in db.WorkTimeSet where (workT.Doctor == t && workT.Start > DateTime.Today) select workT).ToList();
                 db.WorkTimeSet.RemoveRange(workTime);
                 db.SaveChanges();
             }
         }
     }
     else
     {
         MessageBox.Show("Удалять некого");
     }
 }
示例#2
0
 public static bool LoginPasswordCheck(string login, string password, out string mes, out Person pers)
 {
     mes  = "";
     pers = null;
     if (login == "" || password == "")
     {
         mes = "Заполните поля";
         return(false);
     }
     using (ModelMedDBContainer db = new ModelMedDBContainer())
     {
         string[] personInfo = login.Split('_');
         string[] birthInfo  = personInfo[1].Split('.');
         long     hash       = (long)personInfo[0].GetHashCode();
         DateTime birth      = new DateTime(int.Parse(birthInfo[2]), int.Parse(birthInfo[1]), int.Parse(birthInfo[0]));
         pers = db.PersonSet.Find(birth, hash);
         if (pers == null)
         {
             mes = "Логин или пароль введены неверно";
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
示例#3
0
        private void DeleteDoctor_Load(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                Head = (Doctor)db.PersonSet.Find(Head.BirthDate, Head.NameHashID);
                var           temp    = (from docs in db.PersonSet  where (docs is Doctor && docs.NameHashID != Head.NameHashID && docs.BirthDate != Head.BirthDate) select docs).ToList();
                List <Person> doctors = (List <Person>)temp;
                docs = new Doctor[doctors.Count];
                for (int i = 0; i < doctors.Count; i++)
                {
                    docs[i] = (Doctor)doctors[i];
                }

                if (doctors != null)
                {
                    foreach (Doctor d in doctors)
                    {
                        comboBox1.Items.Add(d.FullName + "_" + d.BirthDate.ToShortDateString());
                    }
                }
                else
                {
                    MessageBox.Show("Врачей нет");
                }
            }
        }
示例#4
0
 private void buttonSelectPerson_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "")
     {
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             string[] personInfo = comboBox1.Text.Split('_');
             string[] birthInfo  = personInfo[1].Split('.');
             long     hash       = (long)(personInfo[0]).GetHashCode();
             DateTime birth      = new DateTime(int.Parse(birthInfo[2]), int.Parse(birthInfo[1]), int.Parse(birthInfo[0]));
             Person   pers       = db.PersonSet.Find(birth, hash);
             if (function == 0)
             {
                 Form changeInfo = new ChangePersonInfo(pers);
                 changeInfo.Owner = this;
                 changeInfo.ShowDialog();
             }
             if (function == 1)
             {
                 Form changeMedCard = new ChangeMedCard(((DoctorMenu)Owner).thisDoctor, (Patient)pers);
                 changeMedCard.Show();
             }
         }
     }
     else
     {
         MessageBox.Show("Человек не выбран");
     }
 }
示例#5
0
        private void comboBoxDoctor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxDoctor.SelectedIndex != -1)
            {
                button1.Enabled = false;
                this.comboBoxDate.Items.Clear();

                index = comboBoxDoctor.SelectedIndex;
                using (ModelMedDBContainer db = new ModelMedDBContainer())
                {
                    try
                    {
                        Doctor d = (Doctor)db.PersonSet.Find(DoctorsList[index].BirthDate, DoctorsList[index].NameHashID);

                        string[] distinct = (from dates in d.FreeTimes select dates.Start.ToShortDateString()).Distinct().ToArray();

                        foreach (string doct in distinct)
                        {
                            this.comboBoxDate.Items.Add(doct);
                        }
                    }
                    catch (NullReferenceException)
                    {
                        MessageBox.Show("На данный момент нет времени для записи к этому врачу");
                    }
                }
            }
        }
示例#6
0
        private void RefreshMenu()
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                thisDoctor = (Doctor)db.PersonSet.Find(thisDoctor.BirthDate, thisDoctor.NameHashID);

                this.Text                          = "Врач:" + thisDoctor.FullName;
                this.textBoxName.Text              = thisDoctor.FullName;
                this.textBoxGender.Text            = thisDoctor.Gender;
                this.textBoxBirthDate.Text         = thisDoctor.BirthDate.Date.ToShortDateString();
                this.textNation.Text               = thisDoctor.Nationality;
                this.textLiveAdress.Text           = thisDoctor.LiveAdress;
                this.textRegAdress.Text            = thisDoctor.RegAdress;
                this.textBoxRegDate.Text           = thisDoctor.RegDate.Date.ToShortDateString();
                this.textBoxInsuranceBillNum.Text  = thisDoctor.InsuranceBillNum;
                this.textBoxEducation.Text         = thisDoctor.Education;
                this.textBoxJob.Text               = thisDoctor.Job;
                this.textInsuranceMemberships.Text = thisDoctor.Memberships;
                this.textBoxBirthPlace.Text        = thisDoctor.BirthPlace;
                this.textBoxDocType.Text           = thisDoctor.Documents.DocumentName;
                this.textDocumentN.Text            = thisDoctor.Documents.DocumentNum.ToString();
            }

            //ClinicManageToolStripMenuItem.Enabled = thisDoctor.Job == "Главврач";
            ClinicManageToolStripMenuItem.Enabled = true;
        }
示例#7
0
 public SelectPerson(int func = 0)
 {
     function = func;
     InitializeComponent();
     if (func == 0)
     {
         checkBoxDocs.Show();
         checkBoxPat.Show();
         buttonDelete.Show();
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             foreach (Person per in db.PersonSet)
             {
                 comboBox1.Items.Add(per.FullName + "_" + per.BirthDate.ToShortDateString());
             }
             comboBox1.SelectedIndex = 0;
         }
     }
     if (func == 1)
     {
         checkBoxDocs.Hide();
         checkBoxPat.Hide();
         buttonDelete.Hide();
         checkBoxPat.Checked = true;
     }
 }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                thisDoctor = (Doctor)db.PersonSet.Find(thisDoctor.BirthDate, thisDoctor.NameHashID);

                switch (comboBox1.SelectedIndex)
                {
                case 0:
                {
                    var thisPersonVisits = (from visit in thisDoctor.WorkTimes select new { Время_начала_приёма = visit.Start, Имя_пациента = visit.VisitInfo.Patient.FullName }).ToList();
                    dataGridView1.Columns.Clear();
                    dataGridView1.Columns.Add("Время начала приёма", "Время начала приёма");
                    dataGridView1.Columns.Add("Имя пациента", "Имя пациента");
                    foreach (var s in thisPersonVisits)
                    {
                        dataGridView1.Rows.Add(s.Время_начала_приёма.ToString(), s.Имя_пациента);
                    }

                    dataGridView1.RowHeadersVisible = false;
                    dataGridView1.Refresh();
                    break;
                }

                case 1:
                {
                    var thisPersonVisits = (from visit in thisDoctor.WorkTimes where visit.Start > DateTime.Today select new { Время_начала_приёма = visit.Start, Имя_пациента = visit.VisitInfo.Patient.FullName }).ToList();
                    dataGridView1.Columns.Clear();
                    dataGridView1.Columns.Add("Время начала приёма", "Время начала приёма");
                    dataGridView1.Columns.Add("Имя пациента", "Имя пациента");

                    foreach (var s in thisPersonVisits)
                    {
                        dataGridView1.Rows.Add(s.Время_начала_приёма.ToString(), s.Имя_пациента);
                    }

                    dataGridView1.RowHeadersVisible = false;
                    dataGridView1.Refresh();
                    break;
                }

                case 2:
                {
                    var thisPersonVisits = (from visit in thisDoctor.WorkTimes where (visit.Start <= DateTime.Today)select new { Время_начала_приёма = visit.Start, Имя_пациента = visit.VisitInfo.Patient.FullName }).ToList();
                    dataGridView1.Columns.Clear();
                    dataGridView1.Columns.Add("Время начала приёма", "Время начала приёма");
                    dataGridView1.Columns.Add("Имя врача", "Имя врача");
                    foreach (var s in thisPersonVisits)
                    {
                        dataGridView1.Rows.Add(s.Время_начала_приёма.ToString(), s.Имя_пациента);
                    }

                    dataGridView1.RowHeadersVisible = false;
                    dataGridView1.Refresh();
                    break;
                }
                }
            }
        }
示例#9
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridViewDocRecs.SelectedCells[0] != null && dataGridViewDocRecs.SelectedCells[0].ToString() != "")
     {
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             DoctorRecord dr        = db.DoctorRecordSet.Find(dataGridViewDocRecs.SelectedRows[0].Cells[0].Value, thisDoctor.NameHashID);
             Form         newDocRec = new AddInfoAboutVisit(thisPatient, thisDoctor, dr);
             newDocRec.ShowDialog();
         }
     }
     ReloadForm();
 }
示例#10
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGWIllness.SelectedCells[0].Value != null && dataGWIllness.SelectedCells[0].Value.ToString() != "")
            {
                using (ModelMedDBContainer db = new ModelMedDBContainer())
                {
                    DoctorRecord dr = db.DoctorRecordSet.Find(dataGridViewDocRecs.SelectedRows[0].Cells[0].Value, thisDoctor.NameHashID);


                    Form showInfo = new ShowInfoAboutVisit(dr);
                    showInfo.Show();
                }
            }
        }
示例#11
0
 private void comboBoxJob_SelectedIndexChanged(object sender, EventArgs e)
 {
     button1.Enabled = false;
     this.comboBoxDoctor.Items.Clear();
     using (ModelMedDBContainer db = new ModelMedDBContainer())
     {
         object[] temp = (from doctor in db.PersonSet where (doctor is Doctor)select(doctor)).ToArray();
         string   s    = comboBoxJob.Text;
         DoctorsList = (from doctor in temp  where ((Doctor)doctor).Job == s select(Doctor) doctor).ToArray();
     }
     foreach (Doctor doct in DoctorsList)
     {
         this.comboBoxDoctor.Items.Add(doct.FullName);
     }
 }
示例#12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBoxTime.Text == "")
            {
                MessageBox.Show("Выберите специальность, врача, день и время");
            }
            else
            {
                using (ModelMedDBContainer db = new ModelMedDBContainer())
                {
                    Doctor tempDoctor = (Doctor)db.PersonSet.Find(DoctorsList[index].BirthDate, DoctorsList[index].NameHashID);


                    FreeTime freeTi = (FreeTime)(from times in tempDoctor.FreeTimes
                                                 where (times.Start.Date.ToShortDateString() == comboBoxDate.Text &&
                                                        times.Start.TimeOfDay.ToString() == comboBoxTime.Text)
                                                 select(times)).ToArray()[0];;

                    comboBoxTime.Items.Remove(comboBoxTime.Text);
                    WorkTime workTi = new WorkTime {
                        Start = freeTi.Start, Doctor = tempDoctor, Finish = freeTi.Finish, BirthDate = tempDoctor.BirthDate, NameHashID = tempDoctor.NameHashID
                    };

                    db.FreeTimeSet.Remove(freeTi);
                    Patient t = (Patient)(db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID));
                    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.SaveChanges();
                    MessageBox.Show("Запись совершена");
                    button1.Enabled = false;
                }
            }
        }
示例#13
0
        private void comboBoxDate_SelectedIndexChanged(object sender, EventArgs e)
        {
            button1.Enabled = false;
            this.comboBoxTime.Items.Clear();
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                Doctor   d        = (Doctor)db.PersonSet.Find(DoctorsList[index].BirthDate, DoctorsList[index].NameHashID);
                string   s        = comboBoxDate.Text;
                string[] distinct = (from dates in d.FreeTimes where (dates.Start.ToShortDateString() == s)select(dates.Start.TimeOfDay.ToString())).ToArray();

                foreach (string doct in distinct)
                {
                    this.comboBoxTime.Items.Add(doct);
                }
            }
        }
示例#14
0
 private void Showillnesses_Load(object sender, EventArgs e)
 {
     dataGridView1.ReadOnly = true;
     using (ModelMedDBContainer db = new ModelMedDBContainer())
     {
         thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);
         var IllNames = (from n in thisPatient.Illness select n.Name).ToList();
         dataGridView1.Columns.Add("Название болезни", "Название болезни");
         foreach (string s in IllNames)
         {
             dataGridView1.Rows.Add(s);
         }
         dataGridView1.RowHeadersVisible = false;
         dataGridView1.Refresh();
     }
 }
示例#15
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedCells != null && dataGridView1.SelectedCells.Count != 0)
     {
         using (ModelMedDBContainer db = new ModelMedDBContainer())
         {
             thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);
             var          info = new { dateSt = dataGridView1.SelectedCells[0].Value, name = dataGridView1.SelectedCells[1].Value };
             long         hash = (info.name as string).GetHashCode();
             DateTime     dt   = (DateTime)(info.dateSt);
             DoctorRecord temp = db.DoctorRecordSet.Find(info.dateSt, hash);
             Form         showInfoAboutVisit = new ShowInfoAboutVisit(temp);
             showInfoAboutVisit.Show();
         }
     }
 }
示例#16
0
        private void PatientToDoctor_Load(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                string[] distinct = (from doctor in db.PersonSet where (doctor is Doctor)select(doctor as Doctor).Job).Distinct().ToArray();

                this.comboBoxJob.Items.Remove("Главврач");
                foreach (string job in distinct)
                {
                    this.comboBoxJob.Items.Add(job);
                }
            }
            if (comboBoxJob.Items.Count == 0)
            {
                MessageBox.Show("Врачей нет");
            }
        }
示例#17
0
        private void ShowVisitRecords_Load(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);
                var thisPersonVisits = (from visit in thisPatient.MedCard.DoctorRecord select new { Время_начала_приёма = visit.Date, Имя_врача = visit.Doctor.FullName }).ToList();
                dataGridView1.Columns.Clear();
                dataGridView1.Columns.Add("Время начала приёма", "Время начала приёма");
                dataGridView1.Columns.Add("Имя врача", "Имя врача");
                foreach (var s in thisPersonVisits)
                {
                    dataGridView1.Rows.Add(s.Время_начала_приёма, s.Имя_врача);
                }

                dataGridView1.RowHeadersVisible = false;
                dataGridView1.Refresh();
            }
        }
示例#18
0
        private void ShowDocsVisits_Load(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                thisDoctor = (Doctor)db.PersonSet.Find(thisDoctor.BirthDate, thisDoctor.NameHashID);
                var thisPersonVisits = (from visit in thisDoctor.WorkTimes select new { Время_начала_приёма = visit.Start, Имя_пациента = visit.VisitInfo.Patient.FullName }).ToList();
                dataGridView1.Columns.Clear();
                dataGridView1.Columns.Add("Время начала приёма", "Время начала приёма");
                dataGridView1.Columns.Add("Имя пациента", "Имя пациента");

                foreach (var s in thisPersonVisits)
                {
                    string date = s.Время_начала_приёма.ToString();
                    string name = s.Имя_пациента;

                    dataGridView1.Rows.Add(date, name);
                }
                dataGridView1.RowHeadersVisible = false;
                dataGridView1.Refresh();
            }
        }
示例#19
0
        private void button4_Click(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                Illness temp;

                if (dataGWIllness.SelectedCells[0].Value != null && dataGWIllness.SelectedCells[0].Value.ToString() != "")
                {
                    string s = dataGWIllness.SelectedCells[0].Value.ToString();
                    temp = db.IllnessSet.Find(s.GetHashCode());

                    thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);

                    temp.Patient.Remove(thisPatient);
                    thisPatient.Illness.Remove(temp);
                    db.SaveChanges();
                    dataGWIllness.Rows.Remove(dataGWIllness.Rows[dataGWIllness.SelectedCells[0].RowIndex]);
                }
            }
            ReloadForm();
        }
示例#20
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (ModelMedDBContainer db = new ModelMedDBContainer())
     {
         patient = (Patient)db.PersonSet.Find(patient.BirthDate, patient.NameHashID);
         doctor  = (Doctor)db.PersonSet.Find(doctor.BirthDate, doctor.NameHashID);
         if (doctorRecord == null)
         {
             patient.MedCard.DoctorRecord.Add(new DoctorRecord
             {
                 Anamnesis  = richTextBoxAnamnes.Text,
                 Diagnosis  = richTextBoxDiagnos.Text,
                 Date       = dateTimePicker1.Value,
                 HelpAmount = richTextBoxHelpAmount.Text,
                 HelpType   = richTextBoxHelpType.Text,
                 Result     = richTextBoxResult.Text,
                 DoctorInfo = doctor.FullName,
                 Doctor     = doctor,
                 DoctorID   = doctor.NameHashID,
                 Standarts  = richTextBoxStand.Text
             });
         }
         else
         {
             doctorRecord            = db.DoctorRecordSet.Find(doctorRecord.Date, doctorRecord.DoctorID);
             doctorRecord.Anamnesis  = richTextBoxAnamnes.Text;
             doctorRecord.Diagnosis  = richTextBoxDiagnos.Text;
             doctorRecord.Date       = dateTimePicker1.Value;
             doctorRecord.HelpAmount = richTextBoxHelpAmount.Text;
             doctorRecord.HelpType   = richTextBoxHelpType.Text;
             doctorRecord.Result     = richTextBoxResult.Text;
             doctorRecord.DoctorInfo = doctor.FullName;
             doctorRecord.Doctor     = doctor;
             doctorRecord.DoctorID   = doctor.NameHashID;
             doctorRecord.Standarts  = richTextBoxStand.Text;
         }
         db.SaveChanges();
     }
     this.Close();
 }
示例#21
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                Person info = db.PersonSet.Find(person.BirthDate, person.NameHashID);
                info.LiveAdress       = textLiveAdress.Text;
                info.Nationality      = textNation.Text;
                info.InsuranceBillNum = textBoxInsuranceBillNum.Text;

                if (info is Patient)
                {
                    if (Regex.IsMatch(comboBoxBloodType.Text, @"(-|\+)[1-4]{1}$|[1-4]{1}$"))
                    {
                        if (comboBoxBloodType.Text[0] == '-')
                        {
                            (info as Patient).Rhesus     = "-";
                            (info as Patient).BloodType -= byte.Parse(comboBoxBloodType.Text);
                        }
                        else
                        {
                            (info as Patient).Rhesus    = "+";
                            (info as Patient).BloodType = byte.Parse(comboBoxBloodType.Text);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Невозможное значение для группы крови. Изменение группы крови не будет сохранено");
                    }
                    (info as Patient).WorkIncapacityListNum = textBoxWorkIncapacity.Text;
                    (info as Patient).InsurancePolicyNum    = textInsurancePolicyNum.Text;
                }
                else
                {
                    (info as Doctor).Memberships = textInsuranceMemberships.Text;
                }
                db.SaveChanges();

                this.Close();
            }
        }
示例#22
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("Выберите болезнь из известных или добавьте новую");
     }
 }
示例#23
0
        private void ShowPatientInfo_Load(object sender, EventArgs e)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);

                this.Text                         = "Пациент:" + thisPatient.FullName;
                this.textBoxName.Text             = thisPatient.FullName;
                this.textBoxGender.Text           = thisPatient.Gender;
                this.textBoxBirthDate.Text        = thisPatient.BirthDate.Date.ToShortDateString();
                this.textNation.Text              = thisPatient.Nationality;
                this.textLiveAdress.Text          = thisPatient.LiveAdress;
                this.textRegAdress.Text           = thisPatient.RegAdress;
                this.textBoxRegDate.Text          = thisPatient.RegDate.Date.ToShortDateString();
                this.textBoxInsuranceBillNum.Text = thisPatient.InsuranceBillNum;
                this.textInsurancePolicyNum.Text  = thisPatient.InsurancePolicyNum;
                this.textBoxWorkIncapacity.Text   = thisPatient.WorkIncapacityListNum;
                this.textBoxBloodType.Text        = thisPatient.Rhesus + thisPatient.BloodType.ToString();
                this.textBoxBirthPlace.Text       = thisPatient.BirthPlace;

                this.textBoxDocType.Text = thisPatient.Documents.DocumentName;
                this.textDocumentN.Text  = thisPatient.Documents.DocumentNum.ToString();
            }
        }
示例#24
0
        public static void AnalyseVisits(string fileName)
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                object misValue = System.Reflection.Missing.Value;

                // Создаём экземпляр нашего приложения
                Excel.Application excelApp = new Excel.Application();
                // Создаём экземпляр рабочий книги Excel
                Excel.Workbook workBook;
                // Создаём экземпляр листа Excel
                Excel.Worksheet workSheet;

                workBook  = excelApp.Workbooks.Add(misValue);
                workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1);

                var specials = (from docs in db.PersonSet where (docs is Doctor)select(docs as Doctor).Job).Distinct().ToArray();
                //var workTime = (from works in db.WorkTimeSet group works by works.Start.Date);
                var workT = (from works in db.WorkTimeSet select new { works.Start, works.Doctor.Job }).ToList();
                //List<DateTime> workDays = new List<DateTime>();
                //foreach (DateTime t in workT)
                //    workDays.Add(t.Date);



                DateTime start  = (from works in db.WorkTimeSet select works.Start).Min();
                DateTime finish = (from works in db.WorkTimeSet select works.Start).Max();
                int[,] days = new int[specials.Length, (finish.Date - start.Date).Days + 1];


                //Подсчёт прёмов по профессиям и по дням
                for (int i = 0; i < specials.Length; i++)
                {
                    foreach (var t in workT)
                    {
                        if (specials[i] == t.Job)
                        {
                            days[i, (t.Start.Date - start.Date).Days]++;
                        }
                    }
                }

                //Заполнение строчек и столбцов посчитанными значениями
                for (int i = 1; i <= specials.Length; i++)
                {
                    workSheet.Cells[i, 1] = specials[i - 1];

                    for (int j = 2; j <= days.GetLength(1) + 1; j++)
                    {
                        workSheet.Cells[i, j] = days[i - 1, j - 2];
                    }
                }

                workSheet.Cells[specials.Length + 1, 1] = start;

                for (int i = 2; i <= days.GetLength(1) + 1; i++)
                {
                    workSheet.Cells[specials.Length + 1, i] = start;
                    start = start.AddDays(1);
                }

                /*
                 * //Вычисляем сумму этих чисел
                 * Excel.Range rng = workSheet.Range["A2"];
                 * rng.Formula = "=SUM(A1:L1)";
                 * rng.FormulaHidden = false;
                 *
                 * // Выделяем границы у этой ячейки
                 * Excel.Borders border = rng.Borders;
                 * border.LineStyle = Excel.XlLineStyle.xlContinuous;
                 */

                Excel.ChartObjects xlCharts = (Excel.ChartObjects)workSheet.ChartObjects(Type.Missing);
                Excel.ChartObject  myChart  = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
                // Excel.ChartObject chartObj = myChart.Add(5, 50, 300, 300);
                Excel.Chart chartPage = myChart.Chart;
                //chartPage.ChartType = Excel.XlChartType.xlXYScatterLines;
                //chartPage.ChartType = Excel.XlChartType.xlBarClustered;
                //chartPage.ChartType = Excel.XlChartType.xlLine;

                Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
                Excel.SeriesCollection seriesCollection        = chartPage.SeriesCollection();

                //char a = char.ConvertFromUtf32((char.ConvertToUtf32('A',0) + days.GetLength(1)));

                Excel.Range rngX = workSheet.Range[workSheet.Cells[specials.Length + 1, 2], workSheet.Cells[specials.Length + 1, days.GetLength(1) + 1]];

                //    workSheet.Cells[specials.Length+1, 1], workSheet.Cells[specials.Length+1, days.GetLength(1)]];

                for (int i = 1; i <= specials.Length; i++)
                {
                    Excel.Series series = seriesCollection.NewSeries();
                    Excel.Range  rng    = workSheet.Range[workSheet.Cells[i, 2], workSheet.Cells[i, days.GetLength(1) + 1]];
                    series.XValues = rngX;
                    series.Values  = rng;
                    series.Name    = specials[i - 1];
                }
                workSheet.Columns.AutoFit();
                workBook.SaveAs(fileName, Excel.XlFileFormat.xlExcel12, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

                workBook.Close(true, misValue, misValue);
                excelApp.Quit();

                /*
                 * xlChart.Activate();
                 * xlChart.Select(Type.Missing);
                 *
                 *
                 * //Даем названия осей
                 * ((Excel.Axis)excelApp.ActiveChart.Axes(Excel.XlAxisType.xlCategory,
                 *  Excel.XlAxisGroup.xlPrimary)).HasTitle = true;
                 * ((Excel.Axis)excelApp.ActiveChart.Axes(Excel.XlAxisType.xlCategory,
                 *  Excel.XlAxisGroup.xlPrimary)).AxisTitle.Text = "Дата";
                 * ((Excel.Axis)excelApp.ActiveChart.Axes(Excel.XlAxisType.xlSeriesAxis,
                 *  Excel.XlAxisGroup.xlPrimary)).HasTitle = false;
                 * ((Excel.Axis)excelApp.ActiveChart.Axes(Excel.XlAxisType.xlValue,
                 *  Excel.XlAxisGroup.xlPrimary)).HasTitle = true;
                 * ((Excel.Axis)excelApp.ActiveChart.Axes(Excel.XlAxisType.xlValue,
                 *  Excel.XlAxisGroup.xlPrimary)).AxisTitle.Text = "Приёмов";
                 *
                 * excelApp.ActiveChart.HasTitle = true;
                 * excelApp.ActiveChart.ChartTitle.Text = "Количество приёмов на каждую специальность по дням";
                 *
                 * //Будем отображать легенду
                 * excelApp.ActiveChart.HasLegend = true;
                 * //Расположение легенды
                 * excelApp.ActiveChart.Legend.Position
                 * = Excel.XlLegendPosition.xlLegendPositionLeft;
                 */


                // Открываем созданный excel-файл
                //excelApp.Visible = true;
                //excelApp.UserControl = true;
            }
        }
示例#25
0
        public static bool PatientRegistrationCall(object obj, out string login, out string password)
        {
            RegPatForm regForm = (RegPatForm)obj;

            login    = "";
            password = "";
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                Patient newPatient = new Patient();
                try
                {
                    if (regForm.comboBoxGender.Text == "" || regForm.textSurname.Text == "" ||
                        regForm.textName.Text == "" || regForm.textBoxPassword2.Text == "" ||
                        regForm.textNation.Text == "" || regForm.textLiveAdress.Text == "" ||
                        regForm.textRegAdress.Text == "" || regForm.comboBoxDocType.Text == "" ||
                        regForm.textDocumentN.Text == "" || regForm.textBoxPassword1.Text == "" ||
                        regForm.textBoxBirthPlace.Text == "")
                    {
                        throw (new ArgumentNullException());
                    }

                    if (!(nameCheck.IsMatch(regForm.textSurname.Text) &&
                          nameCheck.IsMatch(regForm.textName.Text)))
                    {
                        throw (new Exception("Имя, фамилия и отчество начинаются с заглавной буквы и могут содержать только буквы русского алфавита."));
                    }
                    else
                    if (regForm.textName2.Text != "" && nameCheck.IsMatch(regForm.textName2.Text))
                    {
                        throw (new Exception("Имя, фамилия и отчество начинаются с заглавной буквы и могут содержать только буквы русского алфавита."));
                    }

                    if (!(numCheck.IsMatch(regForm.textBoxInsuranceBillNum.Text) &&
                          nameCheck.IsMatch(regForm.textInsurancePolicyNum.Text) &&
                          nameCheck.IsMatch(regForm.textBoxWorkIncapacity.Text)))
                    {
                        throw (new Exception("Номера документов могут содержать только цифры."));
                    }


                    newPatient.FullName              = regForm.textSurname.Text + " " + regForm.textName.Text + " " + regForm.textName2.Text;
                    newPatient.Gender                = regForm.comboBoxGender.Text;
                    newPatient.BirthDate             = regForm.dateTimePickerBirthDate.Value.Date;
                    newPatient.Nationality           = regForm.textNation.Text;
                    newPatient.LiveAdress            = regForm.textLiveAdress.Text;
                    newPatient.RegAdress             = regForm.textRegAdress.Text;
                    newPatient.RegDate               = regForm.dateTimePickerRegDate.Value.Date;
                    newPatient.InsuranceBillNum      = regForm.textBoxInsuranceBillNum.Text;
                    newPatient.InsurancePolicyNum    = regForm.textInsurancePolicyNum.Text;
                    newPatient.WorkIncapacityListNum = regForm.textBoxWorkIncapacity.Text;
                    newPatient.BirthPlace            = regForm.textBoxBirthPlace.Text;
                    newPatient.BloodType             = 0;
                    newPatient.Rhesus                = "Неизвестно";
                    newPatient.NameHashID            = newPatient.FullName.GetHashCode();
                    try
                    {
                        long   docNum  = long.Parse(regForm.textDocumentN.Text);
                        string docName = regForm.comboBoxDocType.Text;
                        var    doc     = from d in db.DocumentsSet where (d.DocumentName == docName && d.DocumentNum == docNum) select d;

                        if (docNum < 0)
                        {
                            throw new FormatException();
                        }

                        if (doc.Count() == 0)
                        {
                            newPatient.Documents = new Documents {
                                DocumentName = docName, DocumentNum = docNum, Person = newPatient
                            }
                        }
                        ;
                        else
                        {
                            throw new Exception("Данные документы уже приписаны к другой персоне");
                        }
                    }
                    catch (FormatException)
                    {
                        throw new Exception("В номере документа могут быть только цифры");
                    }
                    catch (Exception a)
                    {
                        throw a;
                    }
                    if (regForm.textBoxPassword1.Text == regForm.textBoxPassword2.Text)
                    {
                        newPatient.Password = regForm.textBoxPassword1.Text;
                    }
                    else
                    {
                        throw new Exception("Пароль не совпадает с введённым во второй раз");
                    }

                    if (db.PersonSet.Find(newPatient.BirthDate, newPatient.NameHashID) != null)
                    {
                        throw new Exception("Данный человек уже зарегистрирован");
                    }
                    newPatient.MedCard         = new MedCard();
                    newPatient.MedCard.Patient = newPatient;
                    db.PersonSet.Add(newPatient);
                    db.SaveChanges();

                    login    = newPatient.FullName + "_" + newPatient.BirthDate.ToShortDateString();
                    password = newPatient.Password;

                    return(true);
                }
                catch (ArgumentNullException)
                {
                    MessageBox.Show("Заполните пустые поля, где не указано \"При наличии\"");
                    return(false);
                }
                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Данные в полях выходят за границы возможных значений");
                    return(false);
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message);
                    return(false);
                }
            }
        }
示例#26
0
        private void ReloadForm()
        {
            using (ModelMedDBContainer db = new ModelMedDBContainer())
            {
                comboBox1.Items.Clear();
                dataGridViewDocRecs.Columns.Clear();
                dataGWIllness.Columns.Clear();
                dataGWVisitInfo.Columns.Clear();

                var illnesses = (from ill in db.IllnessSet select ill.Name).Distinct().ToList();
                foreach (string ill in illnesses)
                {
                    comboBox1.Items.Add(ill);
                }

                thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);

                illnesses = null;
                illnesses = (from ill in thisPatient.Illness select ill.Name).ToList();
                if (illnesses != null)
                {
                    thisPatient = (Patient)db.PersonSet.Find(thisPatient.BirthDate, thisPatient.NameHashID);
                    var IllNames = (from n in thisPatient.Illness select n.Name).ToList();
                    dataGWIllness.Columns.Add("Название болезни", "Название болезни");
                    foreach (string s in IllNames)
                    {
                        dataGWIllness.Rows.Add(s);
                    }
                    dataGWIllness.RowHeadersVisible = false;
                    dataGWIllness.Refresh();
                    /////////
                }


                var visitInfo = (from visits in thisPatient.VisitInfo
                                 where (visits.DateStart < DateTime.Today)
                                 select visits.DateStart).ToList();
                dataGWVisitInfo.Columns.Clear();
                dataGWVisitInfo.Columns.Add("Время приёма", "Время приёма");
                foreach (DateTime s in visitInfo)
                {
                    dataGWVisitInfo.Rows.Add(s.ToString());
                }
                dataGWVisitInfo.RowHeadersVisible = false;
                dataGWVisitInfo.Refresh();


                var doctorRecords = (from recs in thisPatient.MedCard.DoctorRecord select recs).ToList();
                dataGridViewDocRecs.Columns.Clear();
                dataGridViewDocRecs.Columns.Add("Время оказания помощи", "Время оказания помощи");
                dataGridViewDocRecs.Columns.Add("Доктор", "Доктор");
                dataGridViewDocRecs.Columns.Add("Диагноз", "Диагноз");
                dataGridViewDocRecs.Columns.Add("Результат", "Результат");

                foreach (var s in doctorRecords)
                {
                    dataGridViewDocRecs.Rows.Add(s.Date, s.Doctor.FullName, s.Diagnosis, s.Result);
                }

                dataGridViewDocRecs.RowHeadersVisible = false;
                dataGridViewDocRecs.Refresh();
            }
        }
示例#27
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();
                    }
                }
            }
        }
示例#28
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();
        }