Example #1
0
 public static void Main()
 {
     using (var db = new HospitalContext())
     {
         db.Database.Migrate();
         db.SaveChanges();
     }
 }
Example #2
0
        public static void Main()
        {
            using var db = new HospitalContext();

            //var patient = new Patient
            //{
            //    FirstName = "Valeri",
            //    LastName = "Stopkanov",
            //    Address = "Lulin",
            //    Email = "*****@*****.**",
            //    HasInsurance = false,
            //};

            //var medicament = new Medicament
            //{
            //    Name = "Heroin"
            //};

            //db.Medicaments.Find(1).Prescriptions
            //    .Add(new PatientMedicament
            //    {
            //        MedicamentId = 1,
            //        PatientId = 1
            //    });

            var medicament = db.Medicaments.Find(1);
            var patient    = db.Patients.Find(2);

            db.PatientsMedicaments.Add(new PatientMedicament
            {
                Medicament = medicament,
                Patient    = patient
            });

            //db.Database.Migrate();

            //var p = db.PatientsMedicaments.First(pm => pm.PatientId == 1);

            //Console.WriteLine(p.Patient.FirstName);

            //medicament.Prescriptions.Add(new PatientMedicament
            //{
            //    Patient = patient,
            //    Medicament = medicament
            //});

            //db.Medicaments.Add(medicament);

            //patient.Prescriptions.Add(new PatientMedicament
            //{
            //    Medicament = medicament,
            //    Patient = patient
            //});

            //db.Patients.Add(patient);

            db.SaveChanges();
        }
Example #3
0
        static void Main(string[] args)
        {
            var db = new HospitalContext();

            db.Doctors.Add(new Doctor
            {
                Name      = "Ivan",
                Specialty = "Sleeper",
            });

            db.SaveChanges();
        }
        static void Main()
        {
            using (var context = new HospitalContext())
            {
                //context.Database.EnsureDeleted();
                //context.Database.EnsureCreated();
                var patient = new Patient()
                {
                    FirstName = "Pesho",
                    LastName  = "Peshev",
                };

                context.Patients.Add(patient);
                context.SaveChanges();
            }
        }
        public static void Main()
        {
            using (var context = new HospitalContext())
            {
                var doctor = new Doctor();
                doctor.Name      = "Doctor Radeva";
                doctor.Specialty = "Voda";

                var visitation = context.Visitations.First();
                visitation.DoctorId = doctor.DoctorId;

                context.Doctors.Add(doctor);

                context.SaveChanges();
            }
        }
Example #6
0
        private static void Seed(HospitalContext context)
        {
            var patients = new[]
            {
                new Patient
                {
                    FirstName    = "Paul",
                    LastName     = "Jones",
                    Address      = "New York",
                    Email        = "paulj",
                    HasInsurance = true
                },
                new Patient
                {
                    FirstName    = "Jan",
                    LastName     = "Clark",
                    Address      = "Seatle",
                    Email        = "Jonny",
                    HasInsurance = true
                },
                new Patient
                {
                    FirstName    = "Pit",
                    LastName     = "Holms",
                    Address      = "LA",
                    Email        = "pity",
                    HasInsurance = false
                }
            };

            context.Patients.AddRange(patients);

            var doctors = new []
            {
                new Doctor {
                    Name = "Pesho", Specialty = "brain surgeon"
                },
                new Doctor {
                    Name = "Gosho", Specialty = "gynecologist"
                },
                new Doctor {
                    Name = "Ivancho", Specialty = "traumatologist"
                }
            };

            context.Doctors.AddRange(doctors);

            var medicaments = new[]
            {
                new Medicament {
                    Name = "Aspirin"
                },
                new Medicament {
                    Name = "Viagra"
                },
                new Medicament {
                    Name = "Antibiotic"
                },
            };

            context.Medicaments.AddRange(medicaments);

            var patientmedicament = new[]
            {
                new PatientMedicament {
                    Patient = patients[0], Medicament = medicaments[0]
                },
                new PatientMedicament {
                    Patient = patients[1], Medicament = medicaments[1]
                },
                new PatientMedicament {
                    Patient = patients[2], Medicament = medicaments[2]
                },
            };

            context.Prescriptions.AddRange(patientmedicament);

            var visitations = new[]
            {
                new Visitation {
                    Patient = patients[0], Doctor = doctors[0], Comments = "njama da go bade"
                },
                new Visitation {
                    Patient = patients[1], Doctor = doctors[1], Comments = "bez lekarstva ne stava"
                },
                new Visitation {
                    Patient = patients[2], Doctor = doctors[2], Comments = "dano ne se muchi mnogo"
                },
            };

            context.Visitations.AddRange(visitations);

            var diagnoses = new[]
            {
                new Diagnose {
                    Name = "schizophrenia", Comments = "Lud za vrazvane", Patient = patients[0]
                },
                new Diagnose {
                    Name = "not potent", Comments = "Ne moje da go vdigne", Patient = patients[1]
                },
                new Diagnose {
                    Name = "broken neck", Comments = "няма да ходи повече", Patient = patients[2]
                },
            };

            context.Diagnoses.AddRange(diagnoses);

            context.SaveChanges();
        }
        private static void Seed(HospitalContext db)
        {
            var patients = new[]
            {
                new Patient("Ivan", "Ivanov", "...Ivan's address...", "*****@*****.**", true),
                new Patient("Petar", "Petrov", "...Petar's address...", "*****@*****.**", true),
                new Patient("Stoyan", "Stoyanov", "...Stoyan's address...", "*****@*****.**", true),
                new Patient("Minka", "Petkova", "...Minka's address...", "*****@*****.**", true)
            };

            db.Patients.AddRange(patients);

            var doctors = new[]
            {
                new Doctor("Oh, boli", "Тraumatologist"),
                new Doctor("Zhivago", "Physician"),
                new Doctor("Strange", "Surgeon"),
                new Doctor("Who", "Neurologist"),
            };

            db.Doctors.AddRange(doctors);

            var date1  = new DateTime(2017, 06, 02);
            var date2  = new DateTime(2017, 06, 03);
            var date3  = new DateTime(2017, 07, 17);
            var date4  = new DateTime(2017, 08, 09);
            var visits = new[]
            {
                new Visitation(date1, "Needs more meds", patients[0], doctors[0]),
                new Visitation(date1, "Needs more meds", patients[1], doctors[0]),
                new Visitation(date1, "Needs less meds", patients[2], doctors[0]),
                new Visitation(date1, "Needs more meds", patients[3], doctors[0]),
                new Visitation(date2, "Patient checked, feels well", patients[0], doctors[1]),
                new Visitation(date2, "Patient checked, feels not so well", patients[1], doctors[1]),
                new Visitation(date2, "Patient checked, feels very well", patients[2], doctors[1]),
                new Visitation(date2, "Patient checked, feels well", patients[3], doctors[1]),
                new Visitation(date3, "Discharging soon", patients[0], doctors[2]),
                new Visitation(date3, "Good improvement", patients[1], doctors[2]),
                new Visitation(date3, "Good for discharging", patients[2], doctors[2]),
                new Visitation(date3, "Good for discharging", patients[3], doctors[2]),
                new Visitation(date4, "Good for discharging", patients[0], doctors[3]),
                new Visitation(date4, "Needs further treatment", patients[1], doctors[3])
            };

            db.Visitations.AddRange(visits);

            var diagnoses = new[]
            {
                new Diagnose("Broken limb", "Arm or Leg", patients[0]),
                new Diagnose("Respiratory problem", "Complexity?", patients[1]),
                new Diagnose("Neuro problems", "Specify...", patients[2]),
                new Diagnose("Ear infection", "Complexity?", patients[3]),
            };

            db.Diagnoses.AddRange(diagnoses);

            var meds = new[]
            {
                new Medicament("Gips"),
                new Medicament("Broncholytin"),
                new Medicament("Good long Rest..."),
                new Medicament("Otipax"),
            };

            db.Medicaments.AddRange(meds);

            var prescriptions = new[]
            {
                new PatientMedicament()
                {
                    PatientId = 1, Medicament = meds[0]
                },
                new PatientMedicament()
                {
                    PatientId = 2, Medicament = meds[1]
                },
                new PatientMedicament()
                {
                    PatientId = 3, Medicament = meds[2]
                },
                new PatientMedicament()
                {
                    PatientId = 4, Medicament = meds[3]
                },
            };

            db.PatientMedicament.AddRange(prescriptions);

            db.SaveChanges();
        }
Example #8
0
        private static void ParseCommand(string[] tokens, DoctorContoller doctorContoller, HospitalContext context)
        {
            string command = tokens[0];

            if (command == "register")
            {
                doctorContoller.RegisterDoctor(tokens[1], tokens[2], context);
                context.SaveChanges();
                Console.WriteLine("You registred!");
            }
            else if (command == "login")
            {
                if (doctorContoller.IsLogged)
                {
                    Console.WriteLine("You are logged!");
                    return;
                }
                doctorContoller.LoginDoctor(tokens[1], context);
            }
            else if (command == "addPatient")
            {
                string firstName = tokens[1];
                string lastName  = tokens[2];
                string address   = tokens[3];
                string email     = tokens[4];

                if (doctorContoller.IsLogged)
                {
                    doctorContoller.AddPatient(firstName, lastName, address, email, true, context);
                    context.SaveChanges();
                    Console.WriteLine("Ptient add");
                }
                else
                {
                    Console.WriteLine("You are not logged in!");
                }
            }
            else if (command == "addMedicament")
            {
                string name = tokens[1];

                if (!doctorContoller.IsLogged)
                {
                    Console.WriteLine("You are not logged in!");
                    return;
                }

                doctorContoller.AddMedicament(name, context);
                context.SaveChanges();
                Console.WriteLine("Medicament was added!");
            }
            else if (command == "giveMedicamentToPatient")
            {
                if (!doctorContoller.IsLogged)
                {
                    Console.WriteLine("You are not logged in!");
                    return;
                }

                int    patinetId      = int.Parse(tokens[1]);
                string medicamentName = tokens[2];
                doctorContoller.GiveMedicamentToPatient(patinetId, medicamentName, context);
                context.SaveChanges();
                Console.WriteLine("Medicament was given to the selected patient!");
            }
        }