Exemplo n.º 1
0
        public async Task <IEnumerable <object> > GetAllWithRoles(int?limit, int?skip)
        {
            var query = _context.Person
                        .Select(x => new
            {
                id        = x.Id,
                name      = x.Name,
                lastname  = x.Lastname,
                email     = x.Email,
                gender    = x.Gender,
                birthdate = x.Birthdate,
                pesel     = x.Pesel,
                userroles = _context.Userroles
                            .Where(u => u.PersonId == x.Id)
                            .Select(u => new
                {
                    roleId      = u.RoleId,
                    dateofissue = u.Dateofissue,
                    personId    = u.PersonId,
                    roleName    = u.Role.Name
                })
            })
                        .OrderBy(x => x.lastname)
                        .ThenBy(x => x.name);

            var trimmed = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await trimmed.ToListAsync());
        }
        public async Task <IEnumerable <Oldmedicinehistory> > GetAll(int?limit, int?skip)
        {
            var query   = _context.Oldmedicinehistory.OrderByDescending(x => x.Date);
            var trimmed = (IOrderedQueryable <Oldmedicinehistory>) PaginationService <Oldmedicinehistory> .SplitAndLimitQueryable(skip, limit, query);

            return(await trimmed.ToListAsync());
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <object> > DoctorScheduleList(decimal doctorId, bool showRecent, DateTime?start,
                                                                     DateTime?end, int?limit, int?skip)
        {
            var query = _context.Reservation
                        .Where(d => d.DoctorId == doctorId)
                        .Where(x => x.Starttime.Date >= start.Value.Date && x.Endtime.Date <= end.Value.Date);

            query = showRecent
                ? query.Where(x => x.Visit != null && x.Canceled == false).Where(x => x.Starttime.AddMinutes(-30) < DateTime.Now)
                : query.Where(x => x.Visit == null).Where(x => x.Starttime.AddMinutes(30) >= DateTime.Now);

            var anonymousQuery = query.Select(s => new
            {
                reservationId        = s.Id,
                reservationStartTime = s.Starttime,
                reservationEndTime   = s.Endtime,
                isCanceled           = s.Canceled,
                localName            = s.Room.Local.Name,
                roomNumber           = s.Room.Number,
                patientId            = s.Patient.Id,
                patientName          = s.Patient.IdNavigation.Name,
                patientLastname      = s.Patient.IdNavigation.Lastname,
                visit = _context.Visit.FirstOrDefault(y => y.ReservationId == s.Id)
            });

            IOrderedQueryable <object> orderedQuery = showRecent
                ? anonymousQuery.OrderByDescending(x => x.reservationStartTime)
                : anonymousQuery.OrderBy(x => x.reservationStartTime);

            var trimmedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, orderedQuery);

            return(await trimmedQuery.ToListAsync());
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <object> > GetAllByName(string name, int?limit, int?skip)
        {
            var query = _table.Where(x => name == null || x.Name.ToLower().Contains(name.ToLower())).OrderBy(x => x.Name);

            var orderedQuery = PaginationService <T> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
Exemplo n.º 5
0
        public async Task <IEnumerable <object> > RecentOrUpcomingByPatientId(decimal patientId, bool showUpcomingInstead,
                                                                              bool hideCanceledReservations, decimal?doctorId, DateTime?from, DateTime?to, int?limit, int?skip)
        {
            var reservationTypeQuery = _context.Reservation
                                       .Where(x => x.PatientId == patientId)
                                       .Where(x => doctorId == null || x.DoctorId == doctorId)
                                       .Where(x => from == null || x.Starttime.Date >= from.Value.Date)
                                       .Where(x => to == null || x.Endtime.Date <= to.Value.Date);

            if (hideCanceledReservations)
            {
                reservationTypeQuery = reservationTypeQuery.Where(x => x.Canceled == false);
            }

            reservationTypeQuery = showUpcomingInstead
                ? reservationTypeQuery
                                   .Where(x => x.Visit == null)
                                   .Where(x => x.Starttime.AddMinutes(30) >= DateTime.Now)
                : reservationTypeQuery
                                   .Where(x => x.Visit != null)
                                   .Where(x => x.Visit.OnGoing == false)
                                   .Where(x => x.Starttime.AddMinutes(-30) < DateTime.Now);

            var anonymousTypeQuery = reservationTypeQuery.Select(x => new
            {
                reservationId        = x.Id,
                reservationStartTime = x.Starttime,
                reservationEndTime   = x.Endtime,
                isCanceled           = x.Canceled,
                doctorId             = x.DoctorId,
                doctorName           = x.Doctor.IdNavigation.Name,
                doctorLastname       = x.Doctor.IdNavigation.Lastname,
                doctorSpecialization = x.Doctor.Speciality.Name,
                roomNumber           = x.Room.Number,
                localName            = x.Room.Local.Name,
                streetName           = x.Room.Local.Streetname,
                streetNumber         = x.Room.Local.Streetnumber,
                blockNumber          = x.Room.Local.Blocknumber,
                postCode             = x.Room.Local.Postcode,
                cityName             = x.Room.Local.City.Name,
                visit = _context.Visit.FirstOrDefault(y => y.ReservationId == x.Id)
            });

            IOrderedQueryable <object> orderedQuery = showUpcomingInstead
                ? anonymousTypeQuery.OrderBy(x => x.reservationStartTime)
                : anonymousTypeQuery.OrderByDescending(x => x.reservationStartTime);

            var trimmedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, orderedQuery);

            return(await trimmedQuery.ToListAsync());
        }
Exemplo n.º 6
0
        public async Task <IEnumerable <object> > GetAllWithLocalData(int?limit, int?skip)
        {
            var query = _context.Room.Select(x => new
            {
                id        = x.Id,
                number    = x.Number,
                localId   = x.LocalId,
                localName = x.Local.Name
            }).OrderBy(x => x.localName).ThenBy(x => x.number);

            var trimmedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await trimmedQuery.ToListAsync());
        }
        public async Task <IEnumerable <object> > PerformedTreatments(decimal visitId, int?limit, int?skip)
        {
            var query = _context.Treatmentonvisit.Where(x => x.VisitId == visitId)
                        .Select(x => new
            {
                id          = x.Id,
                name        = x.Treatment.Name,
                description = x.Description
            }).OrderBy(x => x.name);

            var orderedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
        public async Task <IEnumerable <object> > DoctorsWorkplacesByName(string localName, decimal?doctorId, int?limit, int?skip)
        {
            var query = _context.Workinghours
                        .Where(x => !doctorId.HasValue || x.DoctorId == doctorId)
                        .Where(x => localName == null || x.Local.Name.ToLower().Contains(localName.ToLower()))
                        .Where(x => x.From.Date >= DateTime.Now.Date)
                        .Select(x => x.Local).Include(x => x.City)
                        .Distinct()
                        .OrderBy(x => x.City.Name)
                        .ThenBy(x => x.Name);

            var orderedQuery = PaginationService <Local> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
Exemplo n.º 9
0
        public async Task <IEnumerable <object> > GetAllByNameOrLastname(string name, int?limit, int?skip)
        {
            var query = _context.Doctor
                        .Where(x => name == null || (x.IdNavigation.Name.ToLower().Contains(name.ToLower()) || x.IdNavigation.Lastname.ToLower().Contains(name.ToLower())))
                        .Select(x => new
            {
                x.Id,
                x.IdNavigation.Name,
                x.IdNavigation.Lastname,
                SpecializationName = x.Speciality.Name,
            }).OrderBy(x => x.Name);

            var orderedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
Exemplo n.º 10
0
        public async Task <IEnumerable <object> > AllByNameOnVisit(decimal visitId, string name, int?limit, int?skip)
        {
            var query = _context.Illnesshistory
                        .Where(x => x.VisitId == visitId)
                        .Where(x => name == null || x.Illness.Name.ToLower().Contains(name.ToLower()))
                        .Select(x => new
            {
                PatientId = x.Visit.Reservation.PatientId,
                Id        = x.Id,
                Name      = x.Illness.Name
            }).OrderBy(x => x.Name);

            IOrderedQueryable <object> orderedQuery = PaginationService <Illness> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
        public async Task <IEnumerable <object> > PrescribedMedicines(decimal visitId, int?limit, int?skip)
        {
            var query = _context.Medicinehistory.Where(x => x.Illnesshistory.VisitId == visitId)
                        .Select(x => new
            {
                medicineName     = x.Medicine.Name,
                medicineDosage   = x.Description,
                medicineId       = x.MedicineId,
                illnessHistoryId = x.IllnesshistoryId,
                startDate        = x.Startdate,
                description      = x.Description
            }).OrderBy(x => x.startDate).ThenBy(x => x.medicineName);

            var orderedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
Exemplo n.º 12
0
        public async Task <IEnumerable <object> > AllByVisitId(decimal visitId, int?limit, int?skip)
        {
            var query = _context.Illnesshistory.Where(x => x.VisitId == visitId)
                        .Select(x => new
            {
                illnessHistoryId = x.Id,
                illnessName      = x.Illness.Name,
                diagnoseDate     = x.Visit.Reservation.Starttime,
                cureDate         = x.Curedate,
                description      = x.Description
            })
                        .OrderBy(x => x.illnessName);

            var orderedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
        public async Task <IEnumerable <object> > TakenMedicines(decimal patientId, int?limit, int?skip)
        {
            var query = _context.Medicinehistory
                        .Where(x => x.Illnesshistory.Visit.Reservation.PatientId == patientId)
                        .Where(x => x.Finishdate == null || x.Finishdate >= DateTime.Now.Date)
                        .Select(x => new
            {
                medicineName     = x.Medicine.Name,
                medicineDosage   = x.Description,
                illnesshistoryId = x.IllnesshistoryId,
                medicineId       = x.MedicineId,
                startdate        = x.Startdate,
                finishdate       = x.Finishdate,
                description      = x.Description
            }).OrderBy(x => x.medicineName).ThenBy(x => x.finishdate == null).ThenBy(x => x.finishdate);

            var orderedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await orderedQuery.ToListAsync());
        }
Exemplo n.º 14
0
        public async Task <IEnumerable <object> > AutoCompleteInfo(string date, decimal?doctorId, decimal?localId, int?limit, int?skip)
        {
            var query = _context.Workinghours
                        .Where(x => !doctorId.HasValue || x.DoctorId == doctorId)
                        .Where(x => !localId.HasValue || x.LocalId == localId)
                        .Where(x => date == null || x.From.Date.ToString().Contains(date))
                        .OrderBy(x => x.From)
                        .Select(x => new
            {
                id   = x.Id,
                name = x.Local.Name + " " +
                       x.From.Date.ToString("dd/MM/yyyy") + ", " +
                       x.From.ToString("HH:mm") + " - " +
                       x.To.ToString("HH:mm")
            });

            var trimmedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, (IOrderedQueryable <object>) query);

            return(await trimmedQuery.ToListAsync());
        }
Exemplo n.º 15
0
        public async Task <IEnumerable <object> > GetAllWithPersonAndSpecializationData(int?limit, int?skip)
        {
            var query = _context.Doctor.Select(x => new
            {
                id         = x.Id,
                speciality = new
                {
                    id   = x.SpecialityId,
                    name = x.Speciality.Name
                },
                person = new
                {
                    name     = x.IdNavigation.Name,
                    lastname = x.IdNavigation.Lastname,
                    email    = x.IdNavigation.Email
                }
            }).OrderBy(x => x.person.name);

            var trimmedQuery = PaginationService <object> .SplitAndLimitQueryable(skip, limit, query);

            return(await trimmedQuery.ToListAsync());
        }