private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (!isAppointmentCheckBox.IsChecked.Value && selectedPatient != null && !string.IsNullOrEmpty(DescriptionTextBox.Text) ||
                isAppointmentCheckBox.IsChecked.Value && selectedPatient != null && !string.IsNullOrEmpty(DescriptionTextBox.Text) && DatePicker.SelectedDate.HasValue && IsDateValid(DatePicker.SelectedDate.Value) && TimePicker.Value.HasValue && IsTimeOfDayValid(TimePicker.Value.Value))
            {
                CheckIn checkin = new CheckIn()
                {
                    AppointedTo   = isAppointmentCheckBox.IsChecked.Value ? DatePicker.SelectedDate.Value.Add(TimePicker.Value.Value.TimeOfDay) : (DateTime?)null,
                    Description   = DescriptionTextBox.Text,
                    IsAppointment = isAppointmentCheckBox.IsChecked.Value
                };

                try
                {
                    await _apiService.PostAsync("patients/" + selectedPatient.Id + "/checkins", checkin);

                    var result = MessageBox.Show("Appointment successfully added", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    if (result == MessageBoxResult.OK)
                    {
                        this.Close();
                    }
                }
                catch (Flurl.Http.FlurlHttpException ex)
                {
                    ErrorTextBox.Text = ex.Message;
                }
            }
            else
            {
                ErrorTextBox.Text = "Invalid input, please make sure you entered everything correctly!";
            }
        }
        private async void FinishButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(DescriptionTextBox.Text) && MessageBox.Show("Are you sure you want to finish? Once you proceed this cannot be undone!", "Finishing Examination", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                HistoryEntry historyEntry = new HistoryEntry()
                {
                    Description = DescriptionTextBox.Text
                };
                try
                {
                    await _apiService.PostAsync <HistoryEntry>("checkins/" + CheckIn.Id + "/is-done", historyEntry);

                    var result = MessageBox.Show("Save Successful!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    if (result == MessageBoxResult.OK)
                    {
                        this.Close();
                    }
                }
                catch (Flurl.Http.FlurlHttpException ex)
                {
                    ErrorTextBox.Text = ex.Message;
                    Console.WriteLine(await ex.GetResponseStringAsync());
                }
            }
            else if (string.IsNullOrEmpty(DescriptionTextBox.Text))
            {
                ErrorTextBox.Text = "A final note is required before finishing!";
            }
        }
 private async void Save_Click(object sender, RoutedEventArgs e)
 {
     if (await IsPatientDataValid())
     {
         Patient newPatient = new Patient
         {
             FirstName        = FirstNameTextBox.Text,
             MiddleName       = MiddleNameTextBox.Text,
             LastName         = LastNameTextBox.Text,
             SocialSecurityId = SocialSecurityIDTextBox.Text,
             DateOfBirth      = DateOfBirthPicker.SelectedDate.Value,
             HomeAddress      = new HomeAddress()
             {
                 Country  = "Hungary",
                 Province = "",
                 City     = AddressCityTextBox.Text,
                 ZIP      = AddressZIPTextBox.Text,
                 Street   = AddressStreetTextBox.Text,
                 Address  = AddressNumberTextBox.Text
             }
         };
         try
         {
             await _apiService.PostAsync("patients", newPatient);
         }
         catch (Flurl.Http.FlurlHttpException ex)
         {
             ErrorLabel.Text = ex.Message;
             Console.WriteLine(ex);
         }
         var result = MessageBox.Show("Patient successfully added", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
         if (result == MessageBoxResult.OK)
         {
             this.Close();
         }
     }
     else
     {
         ErrorLabel.Text = "Invalid input, please make sure you entered everything correctly!";
     }
 }