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("Удалять некого"); } }
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; } } }
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(); }
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(); }
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(); } }
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("Выберите болезнь из известных или добавьте новую"); } }
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(); }
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(); } } } }
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); } } }