Esempio n. 1
0
        static void Main(string[] args)
        {
            var db = new HospitalContext();

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

            db.SaveChanges();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using (HospitalContext context = new HospitalContext())
            {
                DoctorContoller doctorContoller = new DoctorContoller();
                string          input           = "";

                while ((input = Console.ReadLine()) != "exit")
                {
                    string[] tokens = input.Split();

                    ParseCommand(tokens, doctorContoller, context);
                }
            }
        }
        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();
            }
        }
        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();
            }
        }
Esempio n. 5
0
        public static void Main()
        {
            using (var db = new HospitalContext())
            {
                try
                {
                    db.Database.Migrate();

                    Console.WriteLine("Database successfully created!");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 6
0
        static void Main()
        {
            var        db        = new HospitalContext();
            IUIManager uiManager = new ConsoleManager();

            db.Database.Migrate();

            try
            {
                Engine.Run(db, uiManager);
            }
            catch (Exception e)
            {
                uiManager.WriteLine(e.Message);
            }
        }
        public static void Main()
        {
            using (HospitalContext context = new HospitalContext())
            {
                var name = context.Patients.Include(f => f.Prescriptions);

                var last = context.Patients.Select(l => l.LastName);

                foreach (var item in name)
                {
                    System.Console.WriteLine(item.FirstName);
                }
                foreach (var item in last)
                {
                    System.Console.WriteLine(item);
                }
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var context = new HospitalContext();

            context.Database.Migrate();

            // while (true)
            // {
            //     var input = Console.ReadLine()!.Split(" ");
            //     var command = input[0];
            //     var arg = input[1];
            //     switch (command.ToLower())
            //     {
            //         case "add":
            //             break;
            //         case "view":
            //             switch (arg.ToLower())
            //             {
            //                 case "patient":
            //                     var patientsDiagnoses = context.Patients
            //                         .Where(p => new[] {p.FirstName, p.LastName}
            //                             .Any(n => n == arg))
            //                         .Select(p => $"{p.FirstName} {p.LastName}{Environment.NewLine}" +
            //                                      $"{string.Join(Environment.NewLine, p.Diagnoses.Select(d => d.Name))}");
            //                     Console.WriteLine(patientsDiagnoses);
            //                     break;
            //                 case "diagnose":
            //                     break;
            //                 default:
            //                     break;
            //             }
            //             break;
            //         case "edit":
            //             break;
            //         case "delete":
            //             break;
            //         default:
            //             Console.WriteLine("Enter again");
            //             break;
            //     }
            // }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            var db = new HospitalContext();

            //db.Database.EnsureDeleted();
            //db.Database.EnsureCreated();
            //DatabaseInitializer.Migrate();

            using (db)
            {
                DatabaseInitializer.ResetDatabase();
                DatabaseInitializer.InitialSeed(db);
                DatabaseInitializer.SeedPatients(db, 5);
            }

            //using (db)
            //{
            //    db.Database.Migrate();
            //}
        }
Esempio n. 10
0
 static void Main()
 {
     /*
      * LoggerFactory SqlCommandLoggerFactory = new LoggerFactory(
      *  new[] {
      *       new ConsoleLoggerProvider((category, level) =>
      *       category == DbLoggerCategory.Database.Command.Name &&
      *       level == LogLevel.Information, true)
      *  });
      *
      * string connectionString = @"Server=(local)\SQLEXPRESS;Database=HospitalDB;Integrated Security=true";
      * DbContextOptionsBuilder<HospitalContext> optionsBuilder = new DbContextOptionsBuilder<HospitalContext>();
      *
      * optionsBuilder
      *  .UseSqlServer(connectionString)
      *  .UseLoggerFactory(SqlCommandLoggerFactory)
      *  .EnableSensitiveDataLogging();
      */
     using (var db = new HospitalContext())
     {
         db.Database.EnsureCreated();
     }
 }
Esempio n. 11
0
 public static void Main(string[] args)
 {
     var context = new HospitalContext();
 }
Esempio n. 12
0
        static void Main()
        {
            var dbContext = new HospitalContext();

            dbContext.Database.EnsureCreated();
        }
 public static void Main(string[] args)
 {
     HospitalContext hospital = new HospitalContext();
 }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            var db = new HospitalContext();

            db.Database.EnsureCreated();
        }
        public static void Main(string[] args)
        {
            var dbContext = new HospitalContext();

            dbContext.Database.Migrate();
        }
Esempio n. 16
0
        public static void Main()
        {
            var db = new HospitalContext();

            db.Database.Migrate();
        }
Esempio n. 17
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();
        }
Esempio n. 18
0
 static void Main(string[] args)
 {
     using (var db = new HospitalContext())
     {
     }
 }
Esempio n. 19
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!");
            }
        }
Esempio n. 20
0
 static void Main(string[] args)
 {
     HospitalContext context = new HospitalContext();
 }
Esempio n. 21
0
 public static void Main()
 {
     using (HospitalContext context = new HospitalContext())
     {
     }
 }
 public static void Main()
 {
     var db = new HospitalContext();
 }
Esempio n. 23
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            using (var context = new HospitalContext())
            {
                Restart(context);

                var patients = context.Patients
                               .Select(p => new
                {
                    p.FirstName,
                    p.LastName,
                    p.Address,
                    p.Email,
                    p.HasInsurance,
                    Diagnoses = p.Diagnoses.Select(c => new
                    {
                        c.Name,
                        c.Comments
                    }),
                    Visitations = p.Visitations.Select(v => new
                    {
                        v.Comments,
                        v.Doctor
                    }),
                    Prescriptions = p.Prescriptions.Select(pm => new
                    {
                        pm.Medicament
                    }).ToArray()
                });

                foreach (var x in patients)
                {
                    Console.WriteLine($"Name: {x.FirstName} {x.LastName}");
                    Console.WriteLine($"Address: {x.Address}");
                    Console.WriteLine($"Email: {x.Email}");
                    Console.WriteLine($"IsInsurance: {x.HasInsurance}");
                    Console.WriteLine($"Diagnoses: ");

                    foreach (var y in x.Diagnoses)
                    {
                        Console.WriteLine($"--{y.Name} -> {y.Comments}");
                    }

                    Console.WriteLine($"Doctor: ");
                    foreach (var z in x.Visitations)
                    {
                        Console.WriteLine($"----{z.Doctor.Name} -> {z.Comments}");
                    }

                    Console.WriteLine($"Medicament: ");
                    foreach (var r in x.Prescriptions)
                    {
                        Console.WriteLine($"------{r.Medicament.Name}");
                    }

                    Console.WriteLine("===================================================================");
                }
            }
        }
        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();
        }
Esempio n. 25
0
 static void Main(string[] args)
 {
     var dbContext = new HospitalContext();
     //dbContext.Database.EnsureDeleted();
     // dbContext.Database.EnsureCreated();
 }
Esempio n. 26
0
        static void Main(string[] args)
        {
            HospitalContext context = new HospitalContext();

            context.Database.EnsureCreated();
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            HospitalContext context = new HospitalContext();

            context.Database.Migrate();
        }
Esempio n. 28
0
 static void Main(string[] args)
 {
     using (HospitalContext context = new HospitalContext())
     {
     }
 }