public List <TTratamiento> getTrataDiagAbiertos(String dni)
        {
            try
            {
                List <TTratamiento> listR = null;
                FisioDBDataContext  dc    = new FisioDBDataContext();
                var historiales           = from historial in dc.THistorial where historial.Dni_paciente == dni && historial.Estado == "Abierto" select historial;
                if (historiales.Count() > 0)
                {
                    listR = new List <TTratamiento>();
                    foreach (THistorial h in historiales)
                    {
                        var tratamientos = from trata in dc.TTratamiento where trata.Id_historial == h.Id && trata.Estado == "Abierto" select trata;
                        if (tratamientos.Count() > 0)
                        {
                            listR.Add(tratamientos.First());
                        }
                        else
                        {
                            TTratamiento trat = new TTratamiento();
                            trat.Id_historial = h.Id;
                            listR.Add(trat);
                        }
                    }
                }

                return(listR);
            }
            catch (SqlException ex)
            {
                throw (ex);
            }
        }
        public void cerrarTratamiento(TTratamiento t)
        {
            try
            {
                FisioDBDataContext dc = new FisioDBDataContext();


                var tratamientos = from tratamiento in dc.TTratamiento where tratamiento.Id_historial == t.Id_historial && tratamiento.Id_terapia == t.Id_terapia select tratamiento;
                if (tratamientos.Count() == 0)
                {
                    throw new ErrorDatosInexistentesException();
                }
                TTratamiento tra = tratamientos.First();
                tra.Estado = t.Estado;
                tra.F_fin  = t.F_fin;

                dc.SubmitChanges();
            }
            catch (SqlException ex)
            {
                throw (ex);
            }
            catch (ErrorDatosInexistentesException ex)
            {
                throw ex;
            }
        }
Exemple #3
0
 public VTratamiento(TPaciente p, TTratamiento t, String nomTerapia, String nomD)
 {
     this.nomT        = nomTerapia;
     this.nomDiag     = nomD;
     this.paciente    = p;
     this.tratamiento = t;
     this.InitializeComponent();
 }
        private void listViewPac_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (listViewTrat.SelectedIndex != -1)
            {
                TTratamiento t    = listTratamientos.ElementAt(listViewTrat.SelectedIndex);
                TTerapia     te   = this.getTerapia(t.Id_terapia);
                String       nomT = "*Eliminado*";
                if (te != null)
                {
                    nomT = te.Nombre;
                }
                listViewTrat.SelectedIndex = -1;
                VTratamiento v = new VTratamiento(paciente, t, nomT, nomDiagnostico);
                v.Owner = this;


                v.Show();
                this.Visibility = Visibility.Hidden;
            }
        }
Exemple #5
0
        public void cerrarTratamiento(TTratamiento t)
        {
            IAccesoDatos dao = AccesoDatos.CreateDao();

            try
            {
                dao.cerrarTratamiento(t);
            }
            catch (SqlException ex)
            {
                ErrorSql e = new ErrorSql();
                e.Content = "Error en la conexión con la base de datos, intentelo de nuevo, si perdura el fallo consulte con su administrador.";
                throw new FaultException <ErrorSql>(e);
            }
            catch (ErrorDatosInexistentesException ex)
            {
                Error e = new Error();
                e.Content = "No  se encuentra el diagnóstico en la BD.";
                throw new FaultException <Error>(e);
            }
        }
Exemple #6
0
        public void registrarTratamiento(TTratamiento t, String dni, DateTime fecha)
        {
            IAccesoDatos dao = AccesoDatos.CreateDao();

            try
            {
                dao.registrarTratamiento(t, dni, fecha);
            }
            catch (SqlException ex)
            {
                ErrorSql e = new ErrorSql();
                e.Content = "Error en la conexión con la base de datos, intentelo de nuevo, si perdura el fallo consulte con su administrador.";
                throw new FaultException <ErrorSql>(e);
            }
            catch (ErrorDatosExistentesException ex)
            {
                Error e = new Error();
                e.Content = ex.Message;
                throw new FaultException <Error>(e);
            }
        }
        public void actualizarTratamientos(TTratamiento t)
        {
            listTratamientos.Add(t);
            String fFin = "";

            if (t.F_fin != null)
            {
                fFin = t.F_fin.Value.ToShortDateString();
            }
            TTerapia te   = this.getTerapia(t.Id_terapia);
            String   nomT = "*Eliminado*";

            if (te != null)
            {
                nomT = te.Nombre;
            }

            _TratCollection.Add(new TratData {
                Terapia = nomT, Estado = t.Estado, FIni = t.F_inicio.ToShortDateString(), FFin = fFin
            });
        }
        private void btnIniTrat_Click(object sender, RoutedEventArgs e)
        {
            if (comboBox1.SelectedIndex != -1)
            {
                lblAvisos.Content = "";
                try
                {
                    TTratamiento t = new TTratamiento();
                    t.Estado        = "Abierto";
                    t.F_inicio      = calendar1.SelectedDate.Value;
                    t.Id_historial  = idHistorial;
                    t.Observaciones = txtObs.Text;
                    t.Id_terapia    = listTerapias.ElementAt(comboBox1.SelectedIndex).Id;


                    ClienteWCF.getServicios().registrarTratamiento(t, paciente.Dni, calendar1.SelectedDate.Value);

                    ((VHistorial)this.Owner).actualizarTerapias();
                    ((VHistorial)this.Owner).actualizarTratamientos();
                    this.Close();
                }
                catch (FaultException <ErrorSql> ex)
                {
                    MessageBox.Show(ex.Detail.Content);
                }
                catch (EndpointNotFoundException ex)
                {
                    MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador.");
                }
                catch (FaultException <Error> ex)
                {
                    if (ex.Detail.Content == "Ya se ha aplicado esta terapia a este diagnóstico.")
                    {
                        lblAvisos.Content = "Ya se ha aplicado esta terapia a este diagnóstico.";
                    }
                    else
                    {
                        // MessageBox.Show(ex.Detail.Content);
                        MessageBoxResult r = MessageBox.Show(ex.Detail.Content, "", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (r == MessageBoxResult.Yes)
                        {
                            /* TSesionCita s = new TSesionCita();
                             * s.Dni_paciente = paciente.Dni;
                             * DateTime time = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day, System.DateTime.Now.Hour, 0, 0);
                             *
                             * s.Fecha = time;
                             * s.Id_historial = idHistorial;
                             * s.Pagado = false;
                             * s.Precio = ClienteFisio.Properties.Settings.Default.precio;
                             * s.Id_terapia = listTerapias.ElementAt(comboBox1.SelectedIndex).Id;
                             *
                             * try
                             * {
                             *   ClienteWCF.getServicios().registrarCita(s);
                             *   MessageBox.Show("Sesión creada, inicia ahora el tratamiento.");
                             *
                             * }
                             * catch (FaultException<ErrorSql> exc)
                             * {
                             *   MessageBox.Show(exc.Detail.Content);
                             * }
                             * catch (EndpointNotFoundException exc)
                             * {
                             *   MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador.");
                             *
                             * }*/
                            VCitas v = new VCitas(calendar1.SelectedDate.Value);
                            v.Owner        = this;
                            this.IsEnabled = false;
                            v.Show();
                        }
                    }
                }
            }
            else
            {
                lblAvisos.Content = "Elige la terapia que se aplicará.";
            }
        }
        public void registrarTratamiento(TTratamiento t, String dni, DateTime fecha)
        {
            try
            {
                FisioDBDataContext dc = new FisioDBDataContext();
                var sesiones          = from sesion in dc.TSesionCita where sesion.Dni_paciente == dni && sesion.Fecha.Day == fecha.Day && sesion.Fecha.Month == fecha.Month && sesion.Fecha.Year == fecha.Year select sesion;
                if (sesiones.Count() == 0)
                {
                    throw new ErrorDatosExistentesException("No se ha realizado la operación. No se registró una sesión previamente.¿Quieres hacerlo ahora?");
                }

                var tratamientos = from tratamiento in dc.TTratamiento where tratamiento.Id_historial == t.Id_historial && tratamiento.Id_terapia == t.Id_terapia select tratamiento;
                if (tratamientos.Count() > 0)
                {
                    throw new ErrorDatosExistentesException("Ya se ha aplicado esta terapia a este diagnóstico.");
                }

                TSesionCita s = sesiones.First();
                if (s.Id_terapia == 0 || s.Id_terapia == null)
                {
                    s.Id_terapia = t.Id_terapia;
                }
                if (s.Id_historial == 0 || s.Id_historial == null)
                {
                    s.Id_historial = t.Id_historial;
                }
                var historiales = from historial in dc.THistorial where historial.Id == t.Id_historial select historial;
                if (historiales.Count() > 0)
                {
                    THistorial h = historiales.First();
                    if (t.F_inicio.Year < h.F_inicio.Year)
                    {
                        h.F_inicio = t.F_inicio;
                    }
                    else if (t.F_inicio.Year == h.F_inicio.Year)
                    {
                        if (t.F_inicio.Month < h.F_inicio.Month)
                        {
                            h.F_inicio = t.F_inicio;
                        }
                        else if (t.F_inicio.Month == h.F_inicio.Month)
                        {
                            if (t.F_inicio.Day < h.F_inicio.Day)
                            {
                                h.F_inicio = t.F_inicio;
                            }
                        }
                    }
                }

                dc.TTratamiento.InsertOnSubmit(t);

                dc.SubmitChanges();
            }
            catch (SqlException ex)
            {
                throw (ex);
            }
            catch (ErrorDatosExistentesException ex)
            {
                throw ex;
            }
        }