private void btnFilter_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            DateTime startDate = dpStartDate.SelectedDate.Value;
            DateTime endDate = dpEndDate.SelectedDate.Value;

            _paymentFoliosViewModel = new Controllers.CustomViewModel<Model.PaymentFolio>(pf => EntityFunctions.TruncateTime(pf.FolioDate) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(pf.FolioDate) <= EntityFunctions.TruncateTime(endDate), "FolioDate", "asc");
            this.DataContext = _paymentFoliosViewModel;
        }
        private void UpdateGrid()
        {
            _userLoginsViewModel = new Controllers.CustomViewModel<Model.Login>
                                    (login => login.UserId == _userToCheck.UserId && 
                                        EntityFunctions.TruncateTime(login.LoginDate) == EntityFunctions.TruncateTime(dpUserLogins.SelectedDate)
                                        , "LoginDate", "asc");

            this.DataContext = _userLoginsViewModel;
        }
        private void UpdateGrid()
        {
            int selectedPatientId = Convert.ToInt32((cbPatients.SelectedItem as Controllers.ComboBoxItem).Value);

            _authorizationsViewModel = selectedPatientId == -1
                                ? new Controllers.CustomViewModel<Model.Authorization>(a => true, "AuthorizationDate", "desc")
                                : new Controllers.CustomViewModel<Model.Authorization>(a => a.PatientId == selectedPatientId, "AuthorizationDate", "desc");


            this.DataContext = _authorizationsViewModel;
        }
        private void btnSearch_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            int folioNumber;
            if (int.TryParse(txtFolioNumber.Text, out folioNumber) == false)
            {
                MessageBox.Show("Ingrese un número de folio válido", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                _paymentFoliosViewModel = new Controllers.CustomViewModel<Model.PaymentFolio>(pf => pf.FolioNumber == folioNumber, "FolioNumber", "asc");
                this.DataContext = _paymentFoliosViewModel;
            }
		}
        private void UpdateGrid()
        {
            DateTime startDate = dpStartDate.SelectedDate.Value;
            DateTime endDate = dpEndDate.SelectedDate.Value;
            Model.Patient selectedPatient = (cbPatients.SelectedValue as Controllers.ComboBoxItem).Value as Model.Patient;

            if (selectedPatient == null)
                _eventsViewModel = new Controllers.CustomViewModel<Model.Event>(e => EntityFunctions.TruncateTime(e.StartEvent) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(e.StartEvent) <= EntityFunctions.TruncateTime(endDate), "StartEvent", "asc");
            else
                _eventsViewModel = new Controllers.CustomViewModel<Model.Event>(e => EntityFunctions.TruncateTime(e.StartEvent) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(e.StartEvent) <= EntityFunctions.TruncateTime(endDate) && e.PatientId == selectedPatient.PatientId, "StartEvent", "asc");


            this.DataContext = _eventsViewModel;
        }
        private void UpdateGrids()
        {
            _currentSelectedMonth = dtudSelectedMonth.Value.Value;

            _receivedInvoicesViewModel = new Controllers.CustomViewModel<Model.ReceivedInvoice>(i => i.IsDeleted == false && i.InvoiceDate.Value.Month == _currentSelectedMonth.Month && i.InvoiceDate.Value.Year == _currentSelectedMonth.Year, "InvoiceDate", "asc");
            _outgoingInvoicesViewModel = new Controllers.CustomViewModel<Model.OutgoingInvoice>(i => i.IsDeleted == false && i.InvoiceDate.Value.Month == _currentSelectedMonth.Month && i.InvoiceDate.Value.Year == _currentSelectedMonth.Year, "InvoiceDate", "asc");
                        
            dgReceivedInvoices.DataContext = _receivedInvoicesViewModel;
            dgOutgoingInvoices.DataContext = _outgoingInvoicesViewModel;

            decimal receivedInvoicesTotal = _receivedInvoicesViewModel.ObservableData.Sum(i => i.TotalAmount);
            decimal outgoingInvoicesTotal = _outgoingInvoicesViewModel.ObservableData.Sum(i => i.TotalAmount);
            lblTotalMonth.ToolTip = lblTotalMonth.Content = "Diferencia: $" + (outgoingInvoicesTotal - receivedInvoicesTotal).ToString("0.00");
        }
        private void UpdateGrid()
        {
            DateTime startDate = dpStartDate.SelectedDate.Value;
            DateTime endDate = dpEndDate.SelectedDate.Value;
            Model.Patient selectedPatient = (cbPatients.SelectedValue as Controllers.ComboBoxItem).Value as Model.Patient;

            if (selectedPatient == null)
                _paymentsViewModel = new Controllers.CustomViewModel<Model.Payment>(p => EntityFunctions.TruncateTime(p.PaymentDate) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(p.PaymentDate) <= EntityFunctions.TruncateTime(endDate), "PaymentDate", "asc");
            else
                _paymentsViewModel = new Controllers.CustomViewModel<Model.Payment>(p => EntityFunctions.TruncateTime(p.PaymentDate) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(p.PaymentDate) <= EntityFunctions.TruncateTime(endDate) && p.PaymentFolio.PatientId == selectedPatient.PatientId, "PaymentDate", "asc");
            

            this.DataContext = _paymentsViewModel;

            decimal total = _paymentsViewModel.ObservableData.Sum(p => p.Amount);
            lblTotal.ToolTip = lblTotal.Content = "Total: $" + total.ToString("0.00");
        }
        private void UpdateGridFilteredTreatments()
        {
            string searchTerm = txtSearchTerm.Text;

            switch (cbFilter.SelectedIndex)
            {
                case 0:
                    _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPrice>(u => u.IsDeleted == false && u.TreatmentKey.Contains(searchTerm), "TreatmentKey", "asc");
                    break;
                case 1:
                    _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPrice>(u => u.IsDeleted == false && u.Name.Contains(searchTerm), "TreatmentKey", "asc");
                    break;
                case 2:
                    _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPrice>(u => u.IsDeleted == false && u.Type.Contains(searchTerm), "TreatmentKey", "asc");
                    break;
                default:
                    break;
            }

            this.DataContext = _treatmentsViewModel;
        }
        private void UpdateGridFilteredPatients()
        {
            string searchTerm = txtSearchTerm.Text;

            switch (cbFilter.SelectedIndex)
            {
                case 0:
                    _patientsViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.IsDeleted == false && u.FirstName.Contains(searchTerm), "AssignedId", "asc");
                    break;
                case 1:
                    _patientsViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.IsDeleted == false && u.LastName.Contains(searchTerm), "AssignedId", "asc");
                    break;
                case 2:
                    _patientsViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.IsDeleted == false && u.Email.Contains(searchTerm), "AssignedId", "asc");
                    break;
                default:
                    break;
            }

            this.DataContext = _patientsViewModel;
        }
 private void UpdateGrid()
 {
     _providersViewModel = new Controllers.CustomViewModel<Model.ResourceProvider>(rp => rp.IsDeleted == false, "ProviderId", "asc");
     this.DataContext = _providersViewModel;
 }
 private void UpdateGrid()
 {
     _remindersViewModel = new Controllers.CustomViewModel<Model.Reminder>(u => EntityFunctions.TruncateTime(u.AppearDate) == EntityFunctions.TruncateTime(dpReminders.SelectedDate.Value), "AppearDate", "asc");
     this.DataContext = _remindersViewModel;
 }
        private void UpdateGrid()
        {
            DateTime selectedDate = dtudSelectedMonth.Value.Value;

            _invoicesViewModel = cbFilter.SelectedIndex == 0
                                ? new Controllers.CustomViewModel<Model.ReceivedInvoice>(i => i.IsDeleted == false && i.InvoiceDate.Value.Month == selectedDate.Month && i.InvoiceDate.Value.Year == selectedDate.Year, "InvoiceDate", "asc")
                                : new Controllers.CustomViewModel<Model.ReceivedInvoice>(i => i.IsDeleted == false && i.PurchaseDate.Month == selectedDate.Month && i.PurchaseDate.Year == selectedDate.Year, "PurchaseDate", "asc");   
            
            
            this.DataContext = _invoicesViewModel;

            decimal totalMonth = _invoicesViewModel.ObservableData.Sum(i => i.TotalAmount);
            lblTotalMonth.ToolTip = lblTotalMonth.Content = "Total del mes: $" + totalMonth.ToString("0.00");
        }
 private void UpdateGridTreatments()
 {
     _agendaTratmentsViewModel = new Controllers.CustomViewModel<Model.Treatment>(u => u.IsDeleted == false, "TreatmentId", "asc");
     dgAgendaTreatments.DataContext = _agendaTratmentsViewModel;
 }
 private void UpdateGridAllPatients()
 {
     _patientsViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.IsDeleted == false, "AssignedId", "asc");
     this.DataContext = _patientsViewModel;
 }
        private void UpdateGrid()
        {
            DateTime startDate = dpStartDate.SelectedDate.Value;
            DateTime endDate = dpEndDate.SelectedDate.Value;

            _paidsViewModel = new Controllers.CustomViewModel<Model.AmericanExpressPaid>(i => EntityFunctions.TruncateTime(i.PaidDate) >= EntityFunctions.TruncateTime(startDate) && EntityFunctions.TruncateTime(i.PaidDate) <= EntityFunctions.TruncateTime(endDate), "PaidDate", "asc");

            this.DataContext = _paidsViewModel;

            decimal total = _paidsViewModel.ObservableData.Sum(i => i.Total);
            lblTotal.ToolTip = lblTotal.Content = "Total del periodo: $" + total.ToString("0.00");
        }
        private void UpdateGridFilteredPatients()
        {
            string searchTerm = txtSearchTerm.Text;

            if (tcPatients.SelectedIndex == 0)
            {
                _patients = new Controllers.CustomViewModel<Model.Patient>(p => !p.IsDCM && !p.IsDeleted && p.FullName.Contains(searchTerm), "PatientId", "asc");
                dgPatients.DataContext = _patients;
            }
            else
            {
                _patientsDcm = new Controllers.CustomViewModel<Model.Patient>(p => p.IsDCM && !p.IsDeleted && p.FullName.Contains(searchTerm), "PatientId", "asc");
                dgPatientsDcm.DataContext = _patientsDcm;
            }
        }
 private void UpdateGridTreatments()
 {
     _instrumentTreatments = new Controllers.CustomViewModel<Model.Treatment>(_instrument.Treatments.ToList());
     dgTreatments.DataContext = _instrumentTreatments;
 }
 private void UpdateGrid()
 {
     _banksViewModel = new Controllers.CustomViewModel<Model.Bank>(t => t.IsDeleted == false, "BankId", "asc");
     this.DataContext = _banksViewModel;
 }
 private void UpdateGrid()
 {
     _budgetsViewModel = new Controllers.CustomViewModel<Model.Budget>(t => t.IsDeleted == false, "BudgetId", "desc");
     this.DataContext = _budgetsViewModel;
 }
 private void UpdateGrid()
 {
     _authorizationsViewModel = new Controllers.CustomViewModel<Model.DentegraAuthorization>(t => t.PatientId == _selectedPatient.PatientId, "AuthorizationDate", "desc");
     this.DataContext = _authorizationsViewModel;
 }
 private void UpdateGrid()
 {
     _eventStatusChangesViewModel = new Controllers.CustomViewModel<Model.EventStatusChanx>(ec => ec.EventId == _eventToCheck.EventInfo.EventId, "ChangeDate", "asc");
     this.DataContext = _eventStatusChangesViewModel;
 }
 private void UpdateGridAllPatients()
 {
     switch (tcPatients.SelectedIndex)
     {
         case 0:
             _patientsNoHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance == false && u.IsDeleted == false, "AssignedId", "asc");
             dgPatientsNoHI.DataContext = _patientsNoHIViewModel;
             break;
         case 1:
             _patientsWithHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse == false && u.IsDentegra == false && u.IsDeleted == false, "AssignedId", "asc");
             dgPatientsWithHI.DataContext = _patientsWithHIViewModel;
             break;
         case 2:
             _patientsDiverseViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse && u.IsDeleted == false, "AssignedId", "asc");
             dgPatientsDiverse.DataContext = _patientsDiverseViewModel;
             break;
         case 3:
             _patientsDentegraViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDentegra && u.IsDeleted == false, "AssignedId", "asc");
             dgPatientsDentegra.DataContext = _patientsDentegraViewModel;
             break;
         default:
             break;
     }
 }
        private void UpdateGridFilteredPatients()
        {
            string searchTerm = txtSearchTerm.Text;

            if (tcPatients.SelectedIndex == 0) //Not HI
            {
                switch (cbFilter.SelectedIndex)
                {
                    case 0:
                        _patientsNoHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance == false && u.IsDeleted == false && u.FirstName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 1:
                        _patientsNoHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance == false && u.IsDeleted == false && u.LastName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 2:
                        int patientId;
                        int.TryParse(searchTerm, out patientId);

                        _patientsNoHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance == false && u.IsDeleted == false && u.AssignedId == patientId, "AssignedId", "asc");
                        break;
                    default:
                        break;
                }

                dgPatientsNoHI.DataContext = _patientsNoHIViewModel;
            }
            else if (tcPatients.SelectedIndex == 1) //Centauro
            {
                switch (cbFilter.SelectedIndex)
                {
                    case 0:
                        _patientsWithHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse == false && u.IsDentegra == false && u.IsDeleted == false && u.FirstName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 1:
                        _patientsWithHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse == false && u.IsDentegra == false && u.IsDeleted == false && u.LastName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 2:
                        int patientId;
                        int.TryParse(searchTerm, out patientId);

                        _patientsWithHIViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse == false && u.IsDentegra == false && u.IsDeleted == false && u.AssignedId == patientId, "AssignedId", "asc");
                        break;
                    default:
                        break;
                }

                dgPatientsWithHI.DataContext = _patientsWithHIViewModel;
            }
            else if (tcPatients.SelectedIndex == 2) //GS
            {
                switch (cbFilter.SelectedIndex)
                {
                    case 0:
                        _patientsDiverseViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse && u.IsDeleted == false && u.FirstName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 1:
                        _patientsDiverseViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse && u.IsDeleted == false && u.LastName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 2:
                        int patientId;
                        int.TryParse(searchTerm, out patientId);

                        _patientsDiverseViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDiverse && u.IsDeleted == false && u.AssignedId == patientId, "AssignedId", "asc");
                        break;
                    default:
                        break;
                }

                dgPatientsDiverse.DataContext = _patientsDiverseViewModel;
            }
            else //Dentegra
            {
                switch (cbFilter.SelectedIndex)
                {
                    case 0:
                        _patientsDentegraViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDentegra && u.IsDeleted == false && u.FirstName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 1:
                        _patientsDentegraViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDentegra && u.IsDeleted == false && u.LastName.Contains(searchTerm), "AssignedId", "asc");
                        break;
                    case 2:
                        int patientId;
                        int.TryParse(searchTerm, out patientId);

                        _patientsDentegraViewModel = new Controllers.CustomViewModel<Model.Patient>(u => u.HasHealthInsurance && u.IsDentegra && u.IsDeleted == false && u.AssignedId == patientId, "AssignedId", "asc");
                        break;
                    default:
                        break;
                }

                dgPatientsDentegra.DataContext = _patientsDentegraViewModel;
            }
        }
        private void UpdateGridFilteredContacts()
        {
            string searchTerm = txtSearchTerm.Text;

            switch (cbFilter.SelectedIndex)
            {
                case 0:
                    _contactsViewModel = new Controllers.CustomViewModel<Model.Contact>(c => c.FirstName.Contains(searchTerm), "FirstName", "asc");
                    break;
                case 1:
                    _contactsViewModel = new Controllers.CustomViewModel<Model.Contact>(c => c.LastName.Contains(searchTerm), "FirstName", "asc");
                    break;
                case 2:
                    _contactsViewModel = new Controllers.CustomViewModel<Model.Contact>(c => c.Address.Contains(searchTerm), "FirstName", "asc");
                    break;
                default:
                    break;
            }

            this.DataContext = _contactsViewModel;
        }
 private void UpdateGridAllPatients()
 {
     if (tcPatients.SelectedIndex == 0)
     {
         _patients = new Controllers.CustomViewModel<Model.Patient>(p => !p.IsDCM && !p.IsDeleted, "PatientId", "asc");
         dgPatients.DataContext = _patients;
     }
     else
     {
         _patientsDcm = new Controllers.CustomViewModel<Model.Patient>(p => p.IsDCM && !p.IsDeleted, "PatientId", "asc");
         dgPatientsDcm.DataContext = _patientsDcm;
     }
 }
 private void UpdateGridAllContacts()
 {
     _contactsViewModel = new Controllers.CustomViewModel<Model.Contact>(c => true, "FirstName", "asc");
     this.DataContext = _contactsViewModel;
 }
 private void UpdateGridTermPrevWindow()
 {
     _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPrice>(u => u.IsDeleted == false && (u.TreatmentKey.Contains(_searchTermPrevWindow) || u.Name.Contains(_searchTermPrevWindow) || u.Type.Contains(_searchTermPrevWindow)), "TreatmentKey", "asc");
     this.DataContext = _treatmentsViewModel;
 }
        private void UpdateFolioInfo()
        {
            _treatments = _folio.TreatmentPayments
                            .OrderBy(t => t.TreatmentDate)
                            .ToList();

            _payments = _folio.Payments
                            .OrderBy(p => p.PaymentDate)
                            .ToList();

            _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPayment>(_treatments);
            _paymentsViewModel = new Controllers.CustomViewModel<Model.Payment>(_payments);

            dgTreatments.DataContext = _treatmentsViewModel;
            dgPayments.DataContext = _paymentsViewModel;

            UpdateTotals();

            int statementId;
            if (FolioBelongsToStatement(out statementId))
            {
                lblStatementMessage.Visibility = System.Windows.Visibility.Visible;
                lblStatementMessage.ToolTip = lblStatementMessage.Content = lblStatementMessage.Content.ToString() + statementId;
            }
        }
 private void UpdateGridAllTreatments()
 {
     _treatmentsViewModel = new Controllers.CustomViewModel<Model.TreatmentPrice>(u => u.IsDeleted == false, "TreatmentKey", "asc");
     this.DataContext = _treatmentsViewModel;
 }
        private void UpdateGrid()
        {
            DateTime selectedDate = dtudSelectedMonth.Value.Value;

            _generalPaidsViewModel = new Controllers.CustomViewModel<Model.GeneralPaid>(i => i.PurchaseDate.Month == selectedDate.Month && i.PurchaseDate.Year == selectedDate.Year, "PurchaseDate", "asc");   
            
            this.DataContext = _generalPaidsViewModel;

            decimal totalMonth = _generalPaidsViewModel.ObservableData.Sum(i => i.TotalAmount);
            lblTotalMonth.ToolTip = lblTotalMonth.Content = "Total del mes: $" + totalMonth.ToString("0.00");
        }