public static void NewPrescription(int patientId, int medicamentId, HospitalContext context)
        {
            var prescription = new PatientMedicament()
            {
                PatientId    = patientId,
                MedicamentId = medicamentId
            };

            context.Patients.Find(patientId).Prescriptions.Add(prescription);
            context.SaveChanges();
        }
예제 #2
0
        public VisitManager(HospitalContext db, DpApi client, ScheduleManager scheduleManager)
        {
            _db     = db;
            _client = client;

            _mappingRepo     = new DoctorMappingRepository(_db);
            _scheduleRepo    = new ScheduleRepository(_db);
            _visitRepository = new VisitRepository(_db);

            _scheduleManager = new ScheduleManager(_db, _client);
        }
 public void Deletar(int id)
 {
     using (HospitalContext ctx = new HospitalContext())
     {
         if (this.doutor.IdPaciente.Equals(null))
         {
             ctx.Doutores.Remove(ctx.Doutores.Find(id));
         }
         ctx.SaveChanges();
     }
 }
        public async Task <IEnumerable <PatientDto> > SearchAsync(string pattern)
        {
            using (var context = new HospitalContext())
            {
                var patients = await context.Patients
                               .Where(d => d.Name.Contains(pattern))
                               .ToListAsync();

                return(patients);
            }
        }
        public async override Task UpdateAsync(PatientDto model)
        {
            using (var context = new HospitalContext())
            {
                var patient = await context.Patients.FindAsync(model.Id);

                patient.Birthdate = model.Birthdate;
                patient.Name      = model.Name;
                await context.SaveChangesAsync();
            }
        }
        static void Main(string[] args)
        {
            DatabaseInitializer.ResetDatabase(); //това трие базата, прави я с миграциите и я пълни с данните

            using (var db = new HospitalContext())
            {
                //db.Database.EnsureCreated();
                db.Database.Migrate();
                // DatabaseInitializer.SeedPatients(db, 100); // за добавяне на нови 100 човека
            }
        }
예제 #7
0
        public static void ResetDatabase()
        {
            using (var context = new HospitalContext())
            {
                context.Database.EnsureDeleted();

                context.Database.Migrate();

                InitialSeed(context);
            }
        }
        public static void NewPrescription(Patient patient, Medicament medicament, HospitalContext context)
        {
            var prescription = new PatientMedicament()
            {
                Patient    = patient,
                Medicament = medicament
            };

            patient.Prescriptions.Add(prescription);
            context.SaveChanges();
        }
        public async override Task UpdateAsync(DoctorDto model)
        {
            using (var context = new HospitalContext())
            {
                var doctor = await context.Doctors.FindAsync(model.Id);

                doctor.Name           = model.Name;
                doctor.Specialization = model.Specialization;
                await context.SaveChangesAsync();
            }
        }
예제 #10
0
        public List <Patient> GetPatients()
        {
            List <Patient> patientListItems;

            using (var ctx = new HospitalContext())
            {
                var patients =
                    ctx.Patients.Where(patient => patient.IsAdmitted);
                patientListItems = patients.ToList();
            }
            return(patientListItems);
        }
        public async Task RemoveDoctorAsync(int patientId, int doctorId)
        {
            using (var context = new HospitalContext())
            {
                var patient = await context.Patients.FindAsync(patientId);

                var doctor = await context.Doctors.FindAsync(doctorId);

                doctor.Patients.Remove(patient);
                await context.SaveChangesAsync();
            }
        }
예제 #12
0
        //
        // GET: /Doctor/
        public ActionResult PrescribePatient()
        {
            ViewBag.PrescribePatient = "active";
            List <Ward> wards;

            using (var ctx = new HospitalContext())
            {
                wards = ctx.Ward.ToList();
            }

            return(View(wards));
        }
예제 #13
0
        public static void Main()
        {
            HospitalContext context = new HospitalContext();

            using (context)
            {
                context.Database.EnsureCreated();

                Engine engine = new Engine(context);
                engine.Run();
            }
        }
        public async Task AddDoctorToPatientAsync(int doctorId, int pacientId)
        {
            using (var context = new HospitalContext())
            {
                var patient = await context.Patients.FindAsync(pacientId);

                var doctor = await context.Doctors.FindAsync(doctorId);

                patient.Doctors.Add(doctor);
                await context.SaveChangesAsync();
            }
        }
예제 #15
0
        public static Doctor AddDoctor(HospitalContext db, string name, string specialty, string email, string password)
        {
            Doctor doctor = new Doctor
            {
                Name       = name,
                Speciality = specialty
            };

            Authorization.SignIn(db, email, password, doctor);

            return(doctor);
        }
예제 #16
0
        static void AttachingDoctorToHospital()
        {
            string doc = Console.ReadLine();

            using (HospitalContext db = new HospitalContext())
            {
                var doctors = db.Doctor.FirstOrDefault(d => d.FirstName == doc);
                doctors.HospitalId = Convert.ToInt32(Console.ReadLine());
                doctors.Salary     = Convert.ToInt32(Console.ReadLine());
                db.SaveChanges();
            }
        }
예제 #17
0
        //
        // GET: /Receptionist/
        public ActionResult AppointmentSchedule()
        {
            ViewBag.AppointmentSchedule = "active";
            List <DoctorCategory> doctorCategories;

            using (var ctx = new HospitalContext())
            {
                doctorCategories = ctx.DoctorCategory.ToList();
            }
            ViewBag.Category = doctorCategories;
            return(View());
        }
예제 #18
0
 static void ReadAllHospital()
 {
     using (HospitalContext db = new HospitalContext())
     {
         Console.WriteLine("Список больниц:");
         var hospitals = db.Hospital.ToList();
         foreach (var hospital in hospitals)
         {
             Console.WriteLine(string.Join(" ", hospital.Number, hospital.Address));
         }
     }
 }
예제 #19
0
        public ActionResult WritePrescription(FormCollection collection)
        {
            HospitalContext hc = new HospitalContext();
            Prescription    p  = hc.Prescriptions.Find(1);

            p.Advice     = collection["Advice"];
            p.Diagnosis  = collection["Diagnosis"];
            p.Medication = collection["Medication"];
            p.Symptoms   = collection["Symptoms"];
            hc.SaveChanges();
            return(View(p));
        }
예제 #20
0
        public MappingController()
        {
            var db = new HospitalContext();

            client = new DpApi(AppSettings.ClientId, AppSettings.ClientSecret, (Locale)AppSettings.Locale);

            scheduleManager    = new ScheduleManager(db, client);
            repo               = new DoctorMappingRepository(db);
            addressRepo        = new ForeignAddressRepository(db);
            doctorFacilityRepo = new DoctorFacilityRepository(db);
            doctorServiceRepo  = new ForeignDoctorServiceRepository(db);
        }
예제 #21
0
 static void ReadAllPatient()
 {
     using (HospitalContext db = new HospitalContext())
     {
         Console.WriteLine("Список пациенов:");
         var patients = db.Patient.ToList();
         foreach (var patient in patients)
         {
             Console.WriteLine(string.Join(" ", patient.FirstName, patient.LastName, patient.Age, patient.Adress, patient.Complaints));
         }
     }
 }
예제 #22
0
        public NotificationHandler(DpApi client, HospitalContext db = null)
        {
            _db = db ?? new HospitalContext();

            _visitRepo    = new VisitRepository(_db);
            _mappingRepo  = new DoctorMappingRepository(_db);
            _scheduleRepo = new ScheduleRepository(_db);

            _client = client;

            _scheduleManager = new ScheduleManager(_db, _client);
            _visitManager    = new VisitManager(_db, _client, _scheduleManager);
        }
        public List <CountryHeaderDto> GetCountriesList()
        {
            var context = new HospitalContext();

            var countryList = (from countries in context.Countries
                               select new CountryHeaderDto
            {
                Id = countries.Id,
                Name = countries.Name
            }).OrderBy(x => x.Name).ToList();

            return(countryList);
        }
예제 #24
0
 static void DellitHospital()
 {
     using (HospitalContext db = new HospitalContext())
     {
         string hospitalNumber = Console.ReadLine();
         var    hospital       = db.Hospital.Where(h => h.Number == hospitalNumber).ToList();
         if (hospital != null)
         {
             db.Hospital.Remove(hospital[hospital.Count - 1]);
             db.SaveChanges();
         }
     }
 }
예제 #25
0
        public static void Main()
        {
            var dbContext = new HospitalContext();

            using (dbContext)
            {
                // recomended to create database with Migrate()
                // dbContext.Database.Migrate();
                ////dbContext.Database.EnsureCreated();

                // Fills the db with random data
                // DatabaseInitializer.InitialSeed(dbContext);
            }
        }
예제 #26
0
        public ActionResult PatientAccountInfo()
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                HospitalContext hc = new HospitalContext();
                Patient         p  = hc.Patients.Find(Int32.Parse(Session["UserId"].ToString()));

                return(View(p));
            }
        }
예제 #27
0
        public PrimaryController()
        {
            if (System.Web.HttpContext.Current.Session["PatientId"] != null)
            {
                int iid = (int)System.Web.HttpContext.Current.Session["PatientId"];

                using (var ctx = new HospitalContext())
                {
                    int not = ctx.Appointment.Where(c => c.PatientId == iid && c.IsSeen == 2).Select(c => c.Id).ToList().Count;

                    System.Web.HttpContext.Current.Session["PatientNotify"] = not;
                }
            }
        }
예제 #28
0
        static void Main(string[] args)
        {
            //DatabaseInitializer.ResetDatabase();

            using (var context = new HospitalContext())
            {
                DatabaseInitializer.InitialSeed(context);
            }

            //using (var context = new HospitalContext())
            //{
            //    context.Database.EnsureCreated();
            //}
        }
        public void LoginDoctor(string name, HospitalContext context)
        {
            var doctor = context.Doctors.FirstOrDefault(d => d.Name == name);

            if (doctor != null)
            {
                IsLogged = true;
                Console.WriteLine("You successfully loged in!");
            }
            else
            {
                Console.WriteLine("Invalid name!");
            }
        }
예제 #30
0
        public int FillAppointmentInfo(Appointment appointment, string description, List <Medicine> prescription, AppointmentEnumState state)
        {
            if (appointment != null)
            {
                string tempDescription;
                if (string.IsNullOrEmpty(description.Trim()))
                {
                    tempDescription = null;
                }
                else
                {
                    tempDescription = description;
                }
                using (HospitalContext context = new HospitalContext())
                {
                    using (DbContextTransaction transaction = context.Database.BeginTransaction())
                    {
                        try
                        {
                            appointment.Description          = tempDescription;
                            appointment.State                = state;
                            appointment.UpdateTime           = DateTime.Now;
                            context.Entry(appointment).State = EntityState.Modified;
                            int result = context.SaveChanges();

                            var tempAppointment = context.Appointments.Include("Medicines").Single(I => I.Id == appointment.Id);
                            foreach (var item in prescription)
                            {
                                var tempMedicine = context.Medicines.Single(I => I.Id == item.Id);
                                tempAppointment.Medicines.Add(tempMedicine);
                            }
                            context.SaveChanges();

                            transaction.Commit();
                            return(1);
                        }
                        catch (Exception)
                        {
                            transaction.Rollback();
                            return(0);
                        }
                    }
                }
            }
            else
            {
                return(-1);
            }
        }