/// <summary>
        /// This is temporary and obsolete. Will be removed.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AddAppointmentCriteria> GetSlotInfo(TempAddAppointmentRequest request)
        {
            SlotResponse slots;
            Resource     slot;

            try
            {
                slots = await _slotClient.GetSlots(request.Start, request.End);

                slot = FindSlot(request, slots);
            }
            catch (ArgumentNullException e)
            {
                throw new Exception("No Slots found for this time");
            }

            var scheduleId = slot.schedule.reference.Substring(9); //actual id starts at 9th char because of weird contract
            var locationId = GetLocaationId(slots, scheduleId);

            return(new AddAppointmentCriteria()
            {
                PatientId = request.PatientId,
                LocationId = locationId,
                SlotReference = slot.id,
                Start = slot.start ?? new DateTime(),
                End = slot.end ?? new DateTime()
            });
        }
 private static Resource FindSlot(TempAddAppointmentRequest request, SlotResponse slots)
 {
     return(slots.entry
            .Select(e => e.resource)
            .Where(r => r.resourceType == "Slot")
            .First(s =>
                   s.start >= request.Start.Subtract(new TimeSpan(0, 0, 1)) &&
                   s.end <= request.End.AddSeconds(1)));
 }