Пример #1
0
        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;
            }
        }
Пример #2
0
 public async Task AddUserEventAsync([FromBody] Office365.Appointment appointment)
 {
     await _O365Repository.AddEventAppOnly(
         appointment.DoctorPrincipalName,
         appointment.Subject,
         appointment.Start,
         appointment.Start + TimeSpan.FromMinutes(appointment.LengthInMinutes),
         new[] { appointment.PatientEmail },
         appointment.Description,
         appointment.Location);
 }
        public async Task PostAsync(Office365.Appointment appointment)
        {
            string url = $"{_UrlPrefix}api/office365/appointments";

            await PostAsync(url, appointment);
        }
        async Task CreateNewAppointmentAsync()
        {
            try
            {
                IsBusy = true;

                var patient = await client.PatientsService.GetAsync(
                    AppSettings.DefaultPatientId);
                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 (!string.IsNullOrEmpty(MicrosoftGraphService.LoggedInUserEmail))
                {
                    // Add the event to the patient's calendar
                    await MicrosoftGraphService.AddEventUsingRestApiAsync(
                        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;
            }
        }