Beispiel #1
0
        public async Task <Response <PaginationSet <MedicalStaffModel> > > GetAllDoctorByClueAsync(int pageIndex = 1, int pageSize = 20, string clue = "")
        {
            MedicalStaffType[] types = new MedicalStaffType[] { MedicalStaffType.Doctor };
            var result = await _unitOfWork.MedicalStaffRepository.GetAllStaffByTypeAsync(types, pageIndex, pageSize, clue);

            var response = InitSuccessResponse(pageIndex, pageSize, MessageConstant.Load);

            response.Item = GetModelFromEntity(result);
            return(response);
        }
Beispiel #2
0
        public async Task <IActionResult> GetNonRegisteredDoctorAsync(int hospitalId, int pageIndex, int pageSize, string clue = "")
        {
            var types    = new MedicalStaffType[] { MedicalStaffType.Doctor };
            var status   = new MedicalStaffStatus[] { MedicalStaffStatus.Active };
            var response = await _medicalService.GetAvailableStaffSortByDistanceAsync(hospitalId, 50, types, status, clue);

            if (response.Success)
            {
                return(Ok(response.Item));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }
Beispiel #3
0
        protected async Task <Response <PaginationSet <MedicalStaffModel> > > GetAllStaffByHospitalAndTypeAsync(int hospitalId, MedicalStaffType type, MedicalStaffStatus[] status, int pageIndex = 1, int pageSize = Constant.PageSize, bool includeOperatingHours = false, string clue = "")
        {
            var response = InitErrorResponse(pageIndex, pageSize);

            try
            {
                var types  = new MedicalStaffType[] { type };
                var result = await _unitOfWork.MedicalStaffRepository.GetAllStaffByHospitalAndTypeAsync(hospitalId, types,
                                                                                                        status, pageIndex, pageSize, includeOperatingHours, clue);

                response      = InitSuccessResponse(pageIndex, pageSize, MessageConstant.Load);
                response.Item = Mapper.Map <PaginationSet <MedicalStaffModel> >(result);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }

            return(response);
        }
Beispiel #4
0
        protected async Task <Response <PaginationSet <MedicalStaffModel> > > FindNearestStaffReferenceByHospitalAsync(double longitude, double latitude, int radius,
                                                                                                                       List <int> polyClinicIds, string search = "", MedicalStaffType type = MedicalStaffType.Doctor, int pageIndex = 1, int pageSize = Constant.PageSize)
        {
            var response = InitErrorResponse(pageIndex, pageSize);

            try
            {
                var result = await _unitOfWork.MedicalStaffRepository
                             .FindNearestStaffReferenceByHospitalAsync(longitude, latitude, radius, search, type, polyClinicIds, pageIndex, pageSize);

                response      = InitSuccessResponse(pageIndex, pageSize, MessageConstant.Load);
                response.Item = Mapper.Map <PaginationSet <MedicalStaffModel> >(result);
                var userId = GetUserId();

                if (userId > 0)
                {
                    var favoriteDoctors = await _unitOfWork.MedicalStaffFavoriteRepository.FindByAsync(x => x.UserId == userId);

                    var favoriteDoctorIds = favoriteDoctors.Select(x => x.MedicalStaffId).ToList();
                    response.Item.Items = response.Item.Items.Select(x => { x.IsFavorite = favoriteDoctorIds.Contains(x.Id); return(x); }).ToList();
                }
            }catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
Beispiel #5
0
        public async Task <PaginationEntity <MedicalStaff> > FindNearestStaffReferenceByHospitalAsync(double longitude, double latitude, int radius,
                                                                                                      string search, MedicalStaffType type, List <int> polyClinicIds, int pageIndex, int pageSize)
        {
            if (!String.IsNullOrEmpty(search))
            {
                search = search.ToLower();
            }

            var hospitals = await(from h in MediCoreContext.Hospital
                                  join p in MediCoreContext.PolyClinicToHospitalMap on h.Id equals p.HospitalId
                                  let geo = new GeoCoordinate {
                Latitude = h.Latitude ?? 0, Longitude = h.Longitude ?? 0
            }
                                  orderby geo.GetDistanceTo(new GeoCoordinate {
                Latitude = latitude, Longitude = longitude
            })
                                  where h.Status == HospitalStatus.Active && (polyClinicIds.Count == 0 || polyClinicIds.Contains(p.PolyClinicId)) &&
                                  (geo.GetDistanceTo(new GeoCoordinate {
                Latitude = latitude, Longitude = longitude
            }) < radius)
                                  select h.Id).ToListAsync();

            var result = (from m in MediCoreContext.MedicalStaff
                          join h in MediCoreContext.HospitalMedicalStaff on m.Id equals h.MedicalStaffId
                          join hos in MediCoreContext.Hospital on h.HospitalId equals hos.Id
                          join reg in MediCoreContext.Regency on hos.RegencyId equals reg.Id
                          let geo = new GeoCoordinate {
                Latitude = hos.Latitude ?? 0, Longitude = hos.Longitude ?? 0
            }
                          where h.Status == HospitalStaffStatus.Active && m.Status == MedicalStaffStatus.Active &&
                          hospitals.Contains(h.HospitalId) && hos.Status == HospitalStatus.Active &&
                          (String.IsNullOrWhiteSpace(search) == true || (m.FirstName.ToLower().Contains(search) || m.LastName.ToLower().Contains(search)))
                          select new MedicalStaff
            {
                Id = m.Id,
                CreatedById = m.CreatedById,
                AssociatedToUserId = m.CreatedById,
                UpdatedById = m.UpdatedById,
                CreatedDate = m.CreatedDate,
                UpdatedDate = m.UpdatedDate,
                Email = m.Email,
                FirstName = m.FirstName,
                LastName = m.LastName,
                MedicalStaffRegisteredNumber = m.MedicalStaffRegisteredNumber,
                PrimaryPhone = m.PrimaryPhone,
                SecondaryPhone = m.SecondaryPhone,
                Title = m.Title,
                StaffType = m.StaffType,
                Status = m.Status,
                Rating = m.Rating,
                Regency = new Regency {
                    Id = reg.Id, Name = reg.Name
                },
                Distance = geo.GetDistanceTo(new GeoCoordinate {
                    Latitude = latitude, Longitude = longitude
                }),
                Images = (from i in MediCoreContext.Image
                          join map in MediCoreContext.MedicalStaffImage on i.Id equals map.ImageId
                          where map.MedicalStaffId == m.Id && i.IsPrimary == true
                          select new MedicalStaffImage
                {
                    Id = map.Id,
                    Image = new Image
                    {
                        Id = i.Id,
                        FileExtension = i.FileExtension,
                        FileName = i.FileName,
                        ImageUrl = i.ImageUrl
                    }
                }).ToList(),
                MedicalStaffSpecialists = (from s in MediCoreContext.MedicalStaffSpecialist
                                           join map in MediCoreContext.MedicalStaffSpecialistMap on s.Id equals map.MedicalStaffSpecialistId
                                           where map.MedicalStaffId == m.Id
                                           select new MedicalStaffSpecialistMap()
                {
                    Id = map.Id,
                    MedicalStaffSpecialist = new MedicalStaffSpecialist()
                    {
                        Id = s.Id,
                        Name = s.Name,
                        Alias = s.Alias
                    }
                }).ToList(),
            });

            return(new PaginationEntity <MedicalStaff>
            {
                Page = pageIndex,
                PageSize = pageSize,
                TotalCount = await result.CountAsync(),
                Items = await result.Skip((pageIndex - 1) *pageSize).Take(pageSize).ToListAsync()
            });
        }