示例#1
0
        static List <Patient> GetPatientList(HospitalDB db)
        {
            List <Patient> patients = null;

            patients = db.Patients.ToList();
            return(patients);
        }
示例#2
0
        static List <Doctor> GetDoctorList(HospitalDB db)
        {
            List <Doctor> doctors = null;

            doctors = db.Doctors.ToList();
            return(doctors);
        }
示例#3
0
        static List <HospitalDepartment> GetHospitalDepartmentList(HospitalDB db)
        {
            List <HospitalDepartment> hospitalDepartments = null;

            hospitalDepartments = db.HospitalDepartments.ToList();
            return(hospitalDepartments);
        }
示例#4
0
        static void DeletePatient(HospitalDB db, int id)
        {
            var tmp      = db.Patients.Where(a => a.PatientID == id);
            var oldValue = db.Patients.Where(a => a.PatientID == id);

            db.Patients.RemoveRange(oldValue);
            db.SaveChanges();
        }
示例#5
0
 static void ViewDoctors(HospitalDB db)
 {
     Console.WriteLine(". ID  .   Name   . DepartmentID . Speciality . Category .");
     foreach (Doctor doctor in db.Doctors)
     {
         Console.WriteLine(String.Format("|{0,5}|{1,10}|{2,14}|{3,12}|{4,10}|", doctor.DoctorID,
                                         doctor.DoctorName, doctor.HospitalDepartmentID, doctor.Specialty, doctor.Category));
         Console.WriteLine("|_____|__________|______________|____________|__________|");
     }
 }
示例#6
0
        static void UpdatePatient(HospitalDB db, int id, Patient patient)
        {
            Patient oldValue = db.Patients.Where(a => a.PatientID == id).First();

            oldValue.FullName          = patient.FullName;
            oldValue.Address           = patient.Address;
            oldValue.Chamber           = patient.Chamber;
            oldValue.Diagnosis         = patient.Diagnosis;
            oldValue.AttendingDoctorID = patient.AttendingDoctorID;
            oldValue.ArrivalData       = patient.ArrivalData;
            oldValue.StatementData     = patient.StatementData;

            db.SaveChanges();
        }
示例#7
0
        static void GroupPatientlistBySpecialty(HospitalDB db)
        {
            var result =
                from p in db.Patients
                group p by p.AttendingDoctor.Specialty;

            foreach (var group in result)
            {
                Console.WriteLine(group.Key);
                foreach (var t in group)
                {
                    Console.WriteLine(t.FullName);
                }
                Console.WriteLine();
            }
        }
示例#8
0
        static void PatientlistByDoctor(HospitalDB db)
        {
            string nameDoctor = "";
            var    list1      =
                from p in db.Patients
                join d in db.Doctors on p.AttendingDoctorID equals d.DoctorID
                orderby d.DoctorName
                select new { p.FullName, p.Address, d.DoctorName };

            foreach (var item in list1)
            {
                if (nameDoctor != item.DoctorName.ToString())
                {
                    nameDoctor = item.DoctorName.ToString();
                    Console.WriteLine("\n" + nameDoctor);
                }
                Console.WriteLine(item.ToString());
            }
        }
示例#9
0
        static void PatientlistByNameHospitalDepartment(HospitalDB db)
        {
            string nameDep = "";
            var    list1   =
                from h in db.HospitalDepartments
                join d in db.Doctors on h.HospitalDepartmentID equals d.HospitalDepartmentID
                join p in db.Patients on d.DoctorID equals p.AttendingDoctorID
                orderby h.NameOfDepartment
                select new { p.FullName, p.Address, h.NameOfDepartment };

            foreach (var item in list1)
            {
                if (nameDep != item.NameOfDepartment.ToString())
                {
                    nameDep = item.NameOfDepartment.ToString();
                    Console.WriteLine("\n" + nameDep);
                }
                Console.WriteLine(item.ToString());
            }
        }
示例#10
0
 static void AddPatient(HospitalDB db, Patient patient)
 {
     db.Patients.Add(patient);
     db.SaveChanges();
 }
示例#11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var db = new HospitalDB();

            IGI_lab_1.InicializerDB.Inicialize(db);

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Выберите действие");
                Console.WriteLine("1. Вывести записи об отделениях больницы");
                Console.WriteLine("2. Вывести записи о докторах");
                Console.WriteLine("3. Вывести записи о пациентах");
                Console.WriteLine("4. Вывести список пациентов по отделениям больницы");
                Console.WriteLine("5. Вывести список пациентов каждого врача");
                Console.WriteLine("6. Вывести список пациентов сгруппированное по категориям врачей");
                Console.WriteLine("7. Вывести список пациентов сгруппированное по специальностям врачей");
                Console.WriteLine("8. Добавить пациента");
                Console.WriteLine("9. Удалить пациента");
                Console.WriteLine("0. Обновить пациента");

                string action = Console.ReadLine();
                Console.Clear();
                switch (action)
                {
                case "1":
                    ViewHospitalDepartments(GetHospitalDepartmentList(db));
                    break;

                case "2":
                    ViewDoctors(db);
                    break;

                case "3":
                    ViewPatients(GetPatientList(db));
                    break;

                case "4":
                    PatientlistByNameHospitalDepartment(db);
                    break;

                case "5":
                    PatientlistByDoctor(db);
                    break;

                case "6":
                    GroupPatientlistByCategory(db);
                    break;

                case "7":
                    GroupPatientlistBySpecialty(db);
                    break;

                case "8":
                    Console.WriteLine("Введите имя пациента");
                    string fullName = Console.ReadLine();
                    Console.WriteLine("Введите адрес пациента");
                    string address = Console.ReadLine();
                    Console.WriteLine("Введите палату пациента");
                    string chamber = Console.ReadLine();
                    Console.WriteLine("Введите диагноз пациента");
                    string diagnosis = Console.ReadLine();
                    ViewDoctors(db);
                    Console.WriteLine("Введите ID лечащего врача");
                    string attendingDoctorID = Console.ReadLine();
                    Console.WriteLine("Введите дату поступления");
                    DateTime arrivalData = Convert.ToDateTime(Console.ReadLine());

                    AddPatient(db, new Patient
                    {
                        FullName          = fullName,
                        Address           = address,
                        Chamber           = Int32.Parse(chamber),
                        Diagnosis         = diagnosis,
                        AttendingDoctorID = Int32.Parse(attendingDoctorID),
                        ArrivalData       = arrivalData
                    });
                    break;

                case "9":
                    ViewPatients(GetPatientList(db));
                    Console.WriteLine("Введите ID пациента, которого нужно удалить");
                    int id = Int32.Parse(Console.ReadLine());
                    DeletePatient(db, id);
                    break;

                case "0":
                    ViewPatients(GetPatientList(db));
                    Console.WriteLine("Введите ID пациента");
                    id = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Введите имя пациента");
                    fullName = Console.ReadLine();
                    Console.WriteLine("Введите адрес пациента");
                    address = Console.ReadLine();
                    Console.WriteLine("Введите палату пациента");
                    chamber = Console.ReadLine();
                    Console.WriteLine("Введите диагноз пациента");
                    diagnosis = Console.ReadLine();
                    ViewDoctors(db);
                    Console.WriteLine("Введите ID лечащего врача");
                    attendingDoctorID = Console.ReadLine();
                    Console.WriteLine("Введите дату поступления");
                    arrivalData = Convert.ToDateTime(Console.ReadLine());
                    Console.WriteLine("Введите дату выписки");
                    DateTime statementData = Convert.ToDateTime(Console.ReadLine());

                    UpdatePatient(db, id, new Patient
                    {
                        FullName          = fullName,
                        Address           = address,
                        Chamber           = Int32.Parse(chamber),
                        Diagnosis         = diagnosis,
                        AttendingDoctorID = Int32.Parse(attendingDoctorID),
                        ArrivalData       = arrivalData,
                        StatementData     = statementData
                    });
                    break;

                default:
                    break;
                }
                Console.ReadKey();
            }
        }
示例#12
0
        static public void Inicialize(HospitalDB db)
        {
            db.Database.EnsureCreated();

            if (db.HospitalDepartments.Any())
            {
                return;
            }
            List <string> names = new List <string>(new string[] {
                "HospitalDepartment_1", "HospitalDepartment_2", "HospitalDepartment_3"
            });
            Random rand = new Random();

            foreach (string name in names)
            {
                db.HospitalDepartments.Add(new HospitalDepartment
                {
                    NameOfDepartment = name,
                    Capacity         = rand.Next(10, 20)
                });
            }

            db.SaveChanges();

            names = new List <string>(new string[] {
                "Doctor_1", "Doctor_2", "Doctor_3", "Doctor_4", "Doctor_5", "Doctor_6"
            });
            int k = 0;

            foreach (string name in names)
            {
                db.Doctors.Add(new Doctor
                {
                    DoctorName           = name,
                    HospitalDepartmentID = rand.Next(1, 4),
                    Specialty            = "sp" + (k % 3).ToString(),
                    Category             = "ctgr" + (k % 3).ToString()
                });
                k++;
            }

            db.SaveChanges();

            names = new List <string>(new string[] {
                "Patient_1", "Patient_2", "Patient_3", "Patient_4", "Patient_5", "Patient_6",
                "Patient_7", "Patient_8", "Patient_9", "Patient_10", "Patient_11", "Patient_12"
            });
            DateTime today = DateTime.Now.Date;

            k = 0;

            foreach (string name in names)
            {
                db.Patients.Add(new Patient
                {
                    FullName          = name,
                    Address           = "adress",
                    Chamber           = rand.Next(10, 40),
                    Diagnosis         = "",
                    AttendingDoctorID = rand.Next(1, 7),
                    ArrivalData       = today.AddDays(-k),
                    StatementData     = new DateTime()
                });
                k++;
            }

            db.SaveChanges();
        }