Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public override void AceptChanges(bool this_will_close)
        {
            //_Evento.IsDefinitive = chkDefinitivo.Checked;
            _Evento.Motivo    = txtMotivo.Text;
            _Evento.Evolucion = txtEvolution.Text;
            _Evento.Motivo    = txtMotivo.Text;


            if (cmbTipoConsulta.EditValue != null)
            {
                if ((int)cmbTipoConsulta.EditValue != (int)CommonValuesEnum.SeleccioneUnaOpcion)
                {
                    _Evento.IdTipoConsulta = Convert.ToInt32(cmbTipoConsulta.EditValue);
                }
            }

            //No enviar los medicamentos que no sufrieron modificaciones
            var medList = _Evento.PatientMedicaments.Where(p => p.EntityState != Fwk.Bases.EntityState.Unchanged).ToList();

            _Evento.PatientMedicaments.Clear();
            _Evento.PatientMedicaments.AddRange(medList);

            #region   Mapeo de details view a DetailView_Diagnosis
            _Evento.MedicalEventDetailList.Clear();
            var medDetails = _Evento.DetailView_Diagnosis.Where(p => p.EntityState != Fwk.Bases.EntityState.Unchanged).ToList();



            foreach (MedicalEventDetail_ViewBE det_view in medDetails)
            {
                MedicalEventDetailBE det = new MedicalEventDetailBE(det_view);
                det.ActiveRelevance = true;
                _Evento.MedicalEventDetailList.Add(det);
            }
            #endregion

            #region   Mapeo de details view a DetailView_Diagnosis
            medDetails = _Evento.DetailView_MetodosComplementarios.Where(p => p.EntityState != Fwk.Bases.EntityState.Unchanged).ToList();

            foreach (MedicalEventDetail_ViewBE det_view in medDetails)
            {
                MedicalEventDetailBE det = new MedicalEventDetailBE(det_view);
                det.ActiveRelevance = true;
                _Evento.MedicalEventDetailList.Add(det);
            }
            #endregion

            try
            {
                ServiceCalls.UpdateMedicalEvent(_Evento);

                if (this_will_close == false)
                {
                    MessageBox.Show("Datos actualizados con éxito", "Atención de pacientes", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    _Evento.MedicalEventDetailList.Clear();
                    _Evento.PatientMedicaments.Clear();

                    Selected_PatientMedicament = null;

                    _Evento.PatientMedicaments = ServiceCalls.RetrivePatientMedicaments(ServiceCalls.CurrentPatient.PatientId, _Evento.MedicalEventId);


                    MedicalEventDetail_ViewList details = ServiceCalls.RetriveMedicalEventDetails(ServiceCalls.CurrentPatient.PatientId, _Evento.MedicalEventId);

                    _Evento.DetailView_Diagnosis = details.Get_Diagnosis();
                    _Evento.DetailView_MetodosComplementarios = details.Get_Metodo_Complementarios();

                    patientMedicamentViewListBindingSource.DataSource = _Evento.PatientMedicaments;
                    gridControl_Medicaments.RefreshDataSource();
                    gridView_Medicaments.RefreshData();
                    uC_EventDetailsGrid_Diagnosis.Populate(_Evento);
                    uC_EventDetailsGrid_MetComplementario.Populate(_Evento);
                    this.State = Fwk.Bases.EntityUpdateEnum.UPDATED;
                    frmPatientAtencion.PopulateAsync(this);
                }
            }
            catch (Exception ex2)
            {
                ExceptionViewer.Show(ex2);
            }
        }