Ejemplo n.º 1
0
        public IEnumerable GetPatientsByCriterion(int docId, string date)
        {
            List <string> recordedPatients = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                var patients = from t in context.Ticket
                               where t.DoctorsId == docId
                               join p in context.Patient on t.PatientsId equals p.id
                               select new
                {
                    Id         = p.id,
                    LastName   = p.LastName,
                    FirstName  = p.FirstName,
                    Patronymic = p.Patronymic,
                    Date       = t.VisitingDateAndTime
                };

                foreach (var p in patients)
                {
                    if (p.Date.ToShortDateString() == date)
                    {
                        recordedPatients.Add(p.Id + "." + p.LastName + " " + p.FirstName + " " + p.Patronymic + "\t\t" + p.Date.ToShortDateString() + "\t" + p.Date.ToShortTimeString());
                    }
                }
            }

            return(recordedPatients);
        }
Ejemplo n.º 2
0
        public List <string> GetDoctorsBySpecialization(int specializationId)
        {
            List <string> Doctors = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                int therapistId = iCRUDMethods.GetTherapistId();

                var chosenDoctors = from d in context.Doctor.AsNoTracking()
                                    where d.Specialization == specializationId
                                    select d;

                foreach (Doctor doctor in chosenDoctors)
                {
                    if (doctor.Specialization == therapistId)
                    {
                        Doctors.Add(String.Format("{0} {1} {2}; {3}; № кабинета: {4}; Время приёма: {5}; Обслуживаемый участок: {6}", doctor.LastName, doctor.FirstName, doctor.Patronymic, iCRUDMethods.GetSpecializationName(doctor.Specialization), doctor.Room, doctor.Shedule, GetRegionName(doctor.Region.Value)));
                    }
                    else
                    {
                        Doctors.Add(String.Format("{0} {1} {2}; {3}; № кабинета: {4}; Время приёма: {5}", doctor.LastName, doctor.FirstName, doctor.Patronymic, iCRUDMethods.GetSpecializationName(doctor.Specialization), doctor.Room, doctor.Shedule));
                    }
                }
            }

            return(Doctors);
        }
Ejemplo n.º 3
0
        public List <string> GetDoctorsByCriterion(int doctorSpecialization)
        {
            List <string> Doctors = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                int therapistId     = iCRUDMethods.GetTherapistId();
                var selectedDoctors = from d in context.Doctor.AsNoTracking()
                                      where d.Specialization == doctorSpecialization
                                      select d;

                foreach (Doctor doctor in selectedDoctors)
                {
                    if (doctor.Specialization != therapistId)
                    {
                        Doctors.Add(String.Format("{0}.{1} {2} {3}; {4}; № кабинета {5}; Время приёма: {6}", doctor.DocId, doctor.LastName, doctor.FirstName, doctor.Patronymic, iCRUDMethods.GetSpecializationName(doctorSpecialization), doctor.Room, doctor.Shedule));
                    }
                    else
                    {
                        Doctors.Add(String.Format("{0}.{1} {2} {3}; {4}; № кабинета {5}; № участка: {6}; Время приёма: {7}", doctor.DocId, doctor.LastName, doctor.FirstName, doctor.Patronymic, iCRUDMethods.GetSpecializationName(doctorSpecialization), doctor.Room, GetRegionName(doctor.Region.Value), doctor.Shedule));
                    }
                }
            }

            return(Doctors);
        }
Ejemplo n.º 4
0
        public void DiagnosisAdd(string diagnosisName, string description)
        {
            if (description is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(description)));
            }

            if (diagnosisName is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(diagnosisName)));
            }

            using (var context = new PolyclinicDBContext())
            {
                IQueryable query = context.Diagnosis;

                Diagnosis diagnosis = new Diagnosis()
                {
                    DiagnosisName = diagnosisName,
                    Description   = description,
                };

                context.Diagnosis.Add(diagnosis);
                context.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public IEnumerable GetRecordedPatients(int docId, DateTime date)
        {
            List <string> patients = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                var tickets = from t in context.Ticket
                              where t.DoctorsId == docId
                              join p in context.Patient on t.PatientsId equals p.id
                              select new
                {
                    id           = p.id,
                    LastName     = p.LastName,
                    FirstName    = p.FirstName,
                    Patronymic   = p.Patronymic,
                    VisitingTime = t.VisitingDateAndTime
                };
                foreach (var ticket in tickets)
                {
                    if (ticket.VisitingTime.ToShortDateString() == date.ToShortDateString())
                    {
                        patients.Add(ticket.id + ". " + ticket.LastName + " " + ticket.FirstName + " " + ticket.Patronymic + "; Время приёма: " + ticket.VisitingTime.ToShortTimeString());
                    }
                }
            }

            return(patients);
        }
Ejemplo n.º 6
0
        public Entities LoginChecker(string enteredLogin)
        {
            if (enteredLogin is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(enteredLogin)));
            }

            using (PolyclinicDBContext polyclinicDBContext = new PolyclinicDBContext())
            {
                var logins = polyclinicDBContext.Login.AsNoTracking().ToList();

                foreach (Login login in logins)
                {
                    if (login.PolyclinicUser == "Administrator" && enteredLogin == login.UsersLogin)
                    {
                        return(Entities.Administrator);
                    }

                    if (login.PolyclinicUser == "Registrator" && enteredLogin == login.UsersLogin)
                    {
                        return(Entities.Registrator);
                    }

                    if (login.PolyclinicUser == "Doctor" && enteredLogin == login.UsersLogin)
                    {
                        return(Entities.Doctor);
                    }
                }

                return(Entities.Empty);
            }
        }
Ejemplo n.º 7
0
        public void DrugDescriptionChanged(string drugName, string description)
        {
            if (description is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(description)));
            }

            if (drugName is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(drugName)));
            }

            using (var context = new PolyclinicDBContext())
            {
                IQueryable query = context.Drug;

                var drugs = from d in context.Drug
                            where d.DrugName == drugName
                            select d;

                var list = drugs.ToList();
                list[0].Description = description;

                context.SaveChanges();
            }
        }
Ejemplo n.º 8
0
        public void CheckStreets(string streetName, int regionNumber)
        {
            if (streetName is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(streetName)));
            }

            bool exists = false;

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Street> streetQuery = context.Street;
                List <Street>       streets     = streetQuery.ToList();

                foreach (Street street in streets)
                {
                    if (streetName == street.StreetName && regionNumber == street.RegionNumber)
                    {
                        exists = true;
                        break;
                    }
                }

                if (!exists)
                {
                    context.Street.Add(new Street()
                    {
                        RegionNumber = regionNumber, StreetName = streetName
                    });
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        public void DrugAdd(string drugName, string description)
        {
            if (description is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(description)));
            }

            if (drugName is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(drugName)));
            }

            using (var context = new PolyclinicDBContext())
            {
                IQueryable query = context.Drug;

                Drug drug = new Drug()
                {
                    DrugName    = drugName,
                    Description = description,
                };

                context.Drug.Add(drug);
                context.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public IEnumerable GetDoctors()
        {
            List <Doctor> doctors;

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Doctor> query = context.Doctor.AsNoTracking();
                doctors = query.ToList();
            }

            return(doctors);
        }
Ejemplo n.º 11
0
        public IEnumerable GetSpecializations()
        {
            List <Specialization> specializations;

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Specialization> query = context.Specialization.AsNoTracking();
                specializations = query.ToList();
            }

            return(specializations);
        }
Ejemplo n.º 12
0
        public int GetTherapistId()
        {
            int id = 0;

            using (var context = new PolyclinicDBContext())
            {
                var specialization = context.Specialization.Where(s => s.SpecializationName == "Терапевт");
                id = specialization.ToList()[0].id;
            }

            return(id);
        }
Ejemplo n.º 13
0
        public IEnumerable GetPatients()
        {
            List <Patient> patients;

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Patient> query = context.Patient.AsNoTracking();
                patients = query.ToList();
            }

            return(patients);
        }
Ejemplo n.º 14
0
        public Doctor GetDoctorById(int id)
        {
            Doctor doctor;

            using (var context = new PolyclinicDBContext())
            {
                var query = context.Doctor.Where(d => d.DocId == id);
                doctor = query.ToList()[0];
            }

            return(doctor);
        }
Ejemplo n.º 15
0
        public int GetPatientsRegion(int patientsId)
        {
            int patientsRegion = 0;

            using (var context = new PolyclinicDBContext())
            {
                var patient = context.Patient.Where(p => p.id == patientsId);
                patientsRegion = patient.ToList()[0].Region;
            }

            return(patientsRegion);
        }
Ejemplo n.º 16
0
        public IEnumerable GetDoctorsStatistic(int docId)
        {
            List <VisitorStatistics> list = new List <VisitorStatistics>();

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <VisitorStatistics> query = context.VisitorStatistics.AsNoTracking().Where(v => v.DocId == docId);

                list = query.ToList();
            }

            return(list);
        }
Ejemplo n.º 17
0
        public List <PrintedTicket> GetOldPrintedTickets()
        {
            List <Ticket>        OldTickets        = GetOldTickets();
            List <PrintedTicket> OldPrintedTickets = new List <PrintedTicket>();

            using (var context = new PolyclinicDBContext())
            {
                foreach (Ticket ticket in OldTickets)
                {
                    OldPrintedTickets.Add(iCRUDMethods.GetFullTicket(ticket.id));
                }
            }

            return(OldPrintedTickets);
        }
Ejemplo n.º 18
0
        public void DeleteOldTickets()
        {
            List <Ticket> OldTickets = GetOldTickets();

            using (var context = new PolyclinicDBContext())
            {
                foreach (Ticket ticket in OldTickets)
                {
                    context.Ticket.Attach(ticket);
                    context.Ticket.Remove(ticket);
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 19
0
        public string GetPatientsFullInfo(int patientId)
        {
            string patientInfo;

            using (var context = new PolyclinicDBContext())
            {
                var patients = from p in context.Patient.AsNoTracking()
                               where p.id == patientId
                               select p;
                Patient patient = patients.ToList()[0];
                patientInfo = String.Format("ФИО: {0} {1} {2} {8}Пол: {3}{8}Дата рождения: {4}{8}№ участка: {5}, Адрес: {6}{8}Дата регистрации: {7}", patient.LastName, patient.FirstName, patient.Patronymic, patient.Gender == false ? "Женский" : "Мужской", patient.Birth.ToShortDateString(), patient.Region, patient.Address, patient.RegistrationDate.Value.ToShortDateString(), Environment.NewLine);
            }

            return(patientInfo);
        }
Ejemplo n.º 20
0
        public string GetSpecializationName(int specializationId)
        {
            string specializationName;

            using (var context = new PolyclinicDBContext())
            {
                var specializationNames = from s in context.Specialization.AsNoTracking()
                                          where s.id == specializationId
                                          select s;

                specializationName = specializationNames.ToList()[0].SpecializationName;
            }

            return(specializationName);
        }
Ejemplo n.º 21
0
        private string GetRegionName(int regionId)
        {
            string regionName;

            using (var context = new PolyclinicDBContext())
            {
                var regions = from r in context.Region.AsNoTracking()
                              where r.RegionNumber == regionId
                              select r;

                regionName = regions.ToList()[0].RegionName;
            }

            return(regionName);
        }
Ejemplo n.º 22
0
        public void AddTicketToStorage(int patientsId, int doctorsId, DateTime visitingDate)
        {
            using (var context = new PolyclinicDBContext())
            {
                IQueryable query = context.Ticket;

                Ticket ticket = new Ticket();
                ticket.PatientsId          = patientsId;
                ticket.DoctorsId           = doctorsId;
                ticket.VisitingDateAndTime = visitingDate;
                ticket.IsArrived           = false;

                context.Ticket.Add(ticket);
                context.SaveChanges();
            }
        }
Ejemplo n.º 23
0
        public IEnumerable GetRegions()
        {
            List <string> regionsNames = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                var regions = context.Region.AsNoTracking();

                foreach (var region in regions)
                {
                    regionsNames.Add(region.RegionNumber + "." + region.RegionName);
                }
            }

            return(regionsNames);
        }
Ejemplo n.º 24
0
        public IEnumerable GetSpecializationsNamesOnly()
        {
            List <string> specializationsList = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Specialization> query = context.Specialization.AsNoTracking();

                foreach (Specialization specialization in query.ToList())
                {
                    specializationsList.Add(specialization.SpecializationName);
                }
            }

            return(specializationsList);
        }
Ejemplo n.º 25
0
        private List <Ticket> GetOldTickets()
        {
            DateTime      Date = DateTime.Today;
            DateTime      PM   = Date.AddDays(-31);
            List <Ticket> OldTickets;

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Ticket> oldTickets = from t in context.Ticket.AsNoTracking()
                                                 where t.VisitingDateAndTime.CompareTo(PM) < 0
                                                 select t;

                OldTickets = oldTickets.ToList <Ticket>();
            }

            return(OldTickets);
        }
Ejemplo n.º 26
0
        public IEnumerable GetDoctors()
        {
            List <string> doctors = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                IQueryable <Doctor> query = context.Doctor.AsNoTracking();
                var docs = query.ToList();

                foreach (var doctor in docs)
                {
                    doctors.Add(String.Format("{0}.{1} {2} {3}", doctor.DocId, doctor.LastName, doctor.FirstName, doctor.Patronymic));
                }
            }

            return(doctors);
        }
Ejemplo n.º 27
0
        public List <string> GetRegionInfo(int regionId)
        {
            List <string> RegionInfo = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                int therapistId = iCRUDMethods.GetTherapistId();

                var theraphists = from d in context.Doctor.AsNoTracking()
                                  where d.Specialization == therapistId
                                  select d;

                int i = 0;
                foreach (Doctor doctor in theraphists)
                {
                    if (doctor.Region.Value == regionId)
                    {
                        if (i == 0)
                        {
                            RegionInfo.Add("Врачи-терапевты, закреплённые за этим учатском:");
                            i++;
                        }
                        RegionInfo.Add(String.Format("{0} {1} {2}; № кабинета: {3}", doctor.LastName, doctor.FirstName, doctor.Patronymic, doctor.Room));
                    }
                }

                if (i == 0)
                {
                    RegionInfo.Add("За этим учатском нет закреплённых терапевтов");
                }

                var addresses = from s in context.Street.AsNoTracking()
                                where s.RegionNumber == regionId
                                select s;

                RegionInfo.Add("Адреса при участке:");

                foreach (Street street in addresses)
                {
                    RegionInfo.Add(String.Format("Участок №{0}, {1}", street.RegionNumber, street.StreetName));
                }
            }

            return(RegionInfo);
        }
Ejemplo n.º 28
0
        public IEnumerable GetRooms(int specializationId)
        {
            List <int> Rooms = new List <int>();

            using (var context = new PolyclinicDBContext())
            {
                var query = from r in context.Room.AsNoTracking()
                            where r.SpecId == specializationId
                            select r;

                foreach (Room room in query)
                {
                    Rooms.Add(room.RoomNumber);
                }
            }

            return(Rooms);
        }
Ejemplo n.º 29
0
        public IEnumerable GetDoctorsBySpecializationsId(int specializationId)
        {
            List <string> doctors = new List <string>();

            using (var context = new PolyclinicDBContext())
            {
                var docs = from d in context.Doctor.AsNoTracking()
                           where d.Specialization == specializationId
                           select d;

                foreach (var doctor in docs)
                {
                    doctors.Add(String.Format("{0}.{1} {2} {3}", doctor.DocId, doctor.LastName, doctor.FirstName, doctor.Patronymic));
                }
            }

            return(doctors);
        }
Ejemplo n.º 30
0
        public void DoctorCreate(PolyclinicBL.Doctor doctor)
        {
            using (var context = new PolyclinicDBContext())
            {
                Doctor newDoctor = new Doctor();
                newDoctor.LastName       = doctor.LastName;
                newDoctor.FirstName      = doctor.FirstName;
                newDoctor.Patronymic     = doctor.Patronymic;
                newDoctor.Specialization = doctor.Specialization;
                newDoctor.Region         = doctor.Region;
                newDoctor.Room           = doctor.Room;
                newDoctor.Shedule        = doctor.Schedule;
                newDoctor.Interval       = doctor.Interval;

                context.Doctor.Add(newDoctor);
                context.SaveChanges();
            }
        }