protected override async Task InitializeAsync()
 {
     if (_appointmentId.HasValue)
     {
         Appointment = await _client.AppointmentsService.GetAsync(_appointmentId.Value);
     }
 }
Exemple #2
0
        public async void CreateNewAppointment()
        {
            if (this.Patient == null || this.Doctor == null || this.SelectedAppointment == null)
            {
                return;
            }
            IsCreatingAppointment = true;
            ClinicAppointment clinicAppointment = new ClinicAppointment();

            clinicAppointment.Patient    = Patient;
            clinicAppointment.PatientId  = Patient.PatientId;
            clinicAppointment.Doctor     = this.Doctor;
            clinicAppointment.DoctorId   = this.Doctor.DoctorId;
            clinicAppointment.TenantId   = this.Doctor.TenantId;
            clinicAppointment.Speciality = this.Doctor.Speciality;
            clinicAppointment.RoomNumber = this.SelectedAppointment.RoomNumber;
            clinicAppointment.DateTime   = this.SelectedAppointment.StartTime.ToUniversalTime();

            clinicAppointment.Description = "Follow up in order to determine the effectiveness of treatment received";
            clinicAppointment.IsUrgent    = this.SelectedAppointment.IsUrgent;

            await this.CreateNewAppointment(clinicAppointment);

            IsCreatingAppointment = false;
            NavigationHelper.NavigateToPatientInfo();
        }
Exemple #3
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;
            }
        }
Exemple #4
0
        public async Task <int> AddAsync(ClinicAppointment appointment)
        {
            // these properties are updated for demo porpouse.
            if (appointment.RoomNumber == 0)
            {
                appointment.RoomNumber = Randomize.Next(3, 15);
            }

            if (string.IsNullOrEmpty(appointment.Description))
            {
                appointment.Description = "Follow up in order to determine the effectiveness of treatment received";
            }

            _context.ClinicAppointments.Add(appointment);
            await _context.SaveChangesAsync();

            return(appointment.AppointmentId);
        }
Exemple #5
0
 ClinicAppointment Build(ClinicAppointment appointment)
 {
     return(new ClinicAppointment()
     {
         AppointmentId = appointment.AppointmentId,
         DateTime = appointment.DateTime,
         IsUrgent = appointment.IsUrgent,
         Speciality = appointment.Speciality,
         DoctorId = appointment.DoctorId,
         RoomNumber = appointment.RoomNumber,
         Description = appointment.Description,
         PatientId = appointment.PatientId,
         TenantId = appointment.TenantId,
         Doctor = new Doctor()
         {
             Name = appointment.Doctor.Name,
             Picture = appointment.Doctor.Picture,
             Speciality = appointment.Doctor.Speciality
         },
         Patient = appointment.Patient == null ? null : new Patient()
         {
             PatientId = appointment.Patient.PatientId,
             DateOfBirth = appointment.Patient.DateOfBirth,
             Gender = appointment.Patient.Gender,
             Name = appointment.Patient.Name,
             ClinicId = appointment.Patient.ClinicId,
             Picture = appointment.Patient.Picture,
             Age = appointment.Patient.Age,
             Email = appointment.Patient.Email,
             Phone = appointment.Patient.Phone,
             BloodType = appointment.Patient.BloodType,
             Weight = appointment.Patient.Weight,
             Height = appointment.Patient.Height
         }
     });
 }
 public async Task <int> AddAsync([FromBody] ClinicAppointment appointment)
 {
     return(await _AppointmentsRepository.AddAsync(appointment));
 }
Exemple #7
0
        static void CreateClinicAppointments(MyHealthContext context, int tenantId)
        {
            var appointments = new List <ClinicAppointment>();
            var patients     = context.Patients.Select(p => p.PatientId).ToList();
            var doctors      = context.Doctors.ToList();

            foreach (int patientId in patients)
            {
                for (int i = 1; i <= AppointmentMonths; i++)
                {
                    var doctor      = doctors[Randomize.Next(0, doctors.Count - 1)];
                    var appointment = new ClinicAppointment
                    {
                        PatientId   = patientId,
                        DoctorId    = doctor.DoctorId,
                        DateTime    = GetAppointmentDate(i),
                        Speciality  = doctor.Speciality,
                        RoomNumber  = Randomize.Next(3, 15),
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId    = tenantId,
                        IsUrgent    = true
                    };
                    appointments.Add(appointment);

                    doctor      = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId   = patientId,
                        DoctorId    = doctor.DoctorId,
                        DateTime    = GetAppointmentDate(i),
                        Speciality  = doctor.Speciality,
                        RoomNumber  = Randomize.Next(3, 15),
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId    = tenantId,
                        IsUrgent    = false
                    };
                    appointments.Add(appointment);

                    doctor      = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId   = patientId,
                        DoctorId    = doctor.DoctorId,
                        DateTime    = GetAppointmentDate(i),
                        Speciality  = doctor.Speciality,
                        RoomNumber  = Randomize.Next(3, 15),
                        Description = "Evaluate the diagnosis received",
                        TenantId    = tenantId,
                        IsUrgent    = true
                    };
                    appointments.Add(appointment);

                    doctor      = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId   = patientId,
                        DoctorId    = doctor.DoctorId,
                        DateTime    = GetAppointmentDate(i),
                        Speciality  = doctor.Speciality,
                        RoomNumber  = Randomize.Next(3, 15),
                        Description = "Evaluate the effectiveness of treatment received",
                        TenantId    = tenantId,
                        IsUrgent    = false
                    };
                    appointments.Add(appointment);
                }
            }

            context.ClinicAppointments.AddRange(appointments);
            context.SaveChanges();
        }
        public async Task <int> PostAsync(ClinicAppointment appointment)
        {
            string url = $"{_UrlPrefix}api/clinicappointments";

            return(await PostAsync <int, ClinicAppointment>(url, appointment));
        }
Exemple #9
0
 internal async Task CreateNewAppointment(ClinicAppointment appointment)
 {
     await this.client.AppointmentsService.PostAsync(appointment);
 }