Exemplo n.º 1
0
        public bool PushSlots(DoctorFacility doctorFacility)
        {
            var mapping = doctorFacility.DoctorMapping;
            var defaultDoctorService = mapping.ForeignDoctorService;

            if (mapping == null)
            {
                return(false);
            }

            var address   = mapping.ForeignAddress;
            var schedules = _scheduleRepository.GetByDoctorFacility(doctorFacility).Where(s => s.IsFullfilled == false);

            if (schedules.Count() == 0)
            {
                return(false);
            }


            var slotRangeList = schedules.Select(s => new SlotRange()
            {
                Start          = s.Date.Add(s.Start).SetTimeZone(timeZone),
                End            = s.Date.Add(s.End).SetTimeZone(timeZone),
                DoctorServices = ConvertToSlotDoctorServiceList(s.ForeignDoctorService ?? defaultDoctorService, s.Duration)
            }).ToList();

            var putSlotsRequest = new PutSlotsRequest()
            {
                Slots = slotRangeList
            };

            return(_client.PutSlots(address.ForeignFacilityId, address.ForeignDoctorId, address.Id, putSlotsRequest));
        }
Exemplo n.º 2
0
        public bool PushSlots(DoctorFacility doctorFacility)
        {
            var mapping = doctorFacility.DoctorMapping;

            if (mapping == null)
            {
                return(false);
            }

            var maxSlotDate = CultureInfo.InvariantCulture.Calendar.AddWeeks(DateTime.Now, 12);
            var schedules   = GetSchedules(doctorFacility, maxSlotDate);

            if (schedules.Count() == 0)
            {
                return(false);
            }

            var calendarBlocks = CalendarGenerator.MergeSchedules(schedules);

            var address              = mapping.ForeignAddress;
            var groupedSchedules     = schedules.GroupBy(s => s.Date.Date);
            var defaultDoctorService = mapping.ForeignDoctorService;

            var slots = calendarBlocks.Select(b => new SlotRange()
            {
                Start          = b.Start,
                End            = b.End,
                DoctorServices = ConvertToSlotDoctorServiceList(b.DoctorService ?? defaultDoctorService, b.Duration)
            });

            var putSlotsRequest = new PutSlotsRequest()
            {
                Slots = slots.ToList()
            };

            return(_client.PutSlots(address.ForeignFacilityId, address.ForeignDoctorId, address.Id, putSlotsRequest));
        }