async Task CreateNewAppointmentAsync() { try { IsBusy = true; var patient = await client.PatientsService.GetAsync( AppSettings.CurrentPatientId); int roomNumber = _random.Next(AppSettings.MinimumRoomNumber, AppSettings.MaximumRoomNumber); var appointment = new ClinicAppointment { PatientId = patient.PatientId, DoctorId = _selectedDoctor.DoctorId, TenantId = _selectedDoctor.TenantId, Speciality = _selectedDoctor.Speciality, DateTime = _selectedAppointmentDateAndHour, Description = AppSettings.DefaultAppointmentDescription, RoomNumber = roomNumber }; await client.AppointmentsService.PostAsync(appointment); if (AppSettings.OutlookIntegration) { // Add the event to the patient's calendar await MicrosoftGraphService.AddEventAsync( subject : "Clinic Appointment with " + _selectedDoctor.Name, startTime : _selectedAppointmentDateAndHour, endTime : _selectedAppointmentDateAndHour + TimeSpan.FromMinutes(45), attendeeEmails : new string[0], description : AppSettings.DefaultAppointmentDescription, locationDisplayName : $"Room {roomNumber}"); // Add the events to the doctor's calendar. var @event = new Office365.Appointment { DoctorPrincipalName = _selectedDoctor.Email, Subject = "Clinic Appointment with " + patient.Name, Description = AppSettings.DefaultAppointmentDescription, PatientEmail = patient.Email, Start = _selectedAppointmentDateAndHour, LengthInMinutes = 45, Location = $"Room {roomNumber}" }; //TODO: Uncomment to enable doctor calendar integration. //await client.DoctorCalendarService.PostAsync(@event); } await dialogService.AlertAsync("The appointment was created successfully.", "New appointment", OkText); } finally { IsBusy = false; } }
async Task AddHoursRetrievedFromAPIAsync() { var hours = new List <DateTime>(); hours = await client.DoctorsService.GetAvailableHoursAsync(_selectedDoctor.DoctorId, _selectedDate.Day, _selectedDate.Month, _selectedDate.Year); var fi = new DateTimeFormatInfo { AMDesignator = "am", PMDesignator = "pm" }; var actualHours = new List <string>(); foreach (var hour in hours) { var date = hour.ToLocalTime().ToString("h:mm tt", fi); actualHours.Add(date); } // Remove times that are conflicting with doctor's calendar. if (AppSettings.OutlookIntegration) { // Get patient events from calendar. //TODO: Use Rest api instead to workaround issue. Revert to Microsoft Graph Service after the issue is resolved. //events = await MicrosoftGraphService.GetEventsAsync(_selectedDate); PatientEvents = await MicrosoftGraphService.GetEventsAsync(_selectedDate); //TODO: uncomment the following to enable doctor calendar integration. //if (_selectedDoctor != null) //{ // var doctorEvents = await client.DoctorCalendarService.GetDoctorEventsByDayAsync(_selectedDoctor.Email, _selectedDate); // var filteredHours = RemoveConflictingHours(hours, doctorEvents, fi); // actualHours.Clear(); // actualHours.AddRange(filteredHours); //} } PossibleHours.AddRange(actualHours); }