Пример #1
0
        private void BtnGenerar_Click(object sender, EventArgs e)
        {
            if (RdbDiagnostico.Checked)
            {
                CrpSubInformePacienteDiagnostico Crp = new CrpSubInformePacienteDiagnostico();

                Crp.SetParameterValue("@CodEmpresa", CboEmpresa.SelectedValue);
                Crp.SetParameterValue("@FechaDesde", DtDesde.Value.ToShortDateString());
                Crp.SetParameterValue("@FechaHasta", DtHasta.Value.ToShortDateString());

                FrmVisualizarReporte f = new FrmVisualizarReporte();

                f.crystalReportViewer1.ReportSource = Crp;
                f.Show();
            }
            else
            {
                CrpInforme Crp = new CrpInforme();
                Crp.SetParameterValue("@CodEmpresa", CboEmpresa.SelectedValue);
                Crp.SetParameterValue("@FechaDesde", DtDesde.Value.ToShortDateString());
                Crp.SetParameterValue("@FechaHasta", DtHasta.Value.ToShortDateString());
                FrmVisualizarReporte f = new FrmVisualizarReporte();
                //SE VISUALIZA EL REPORTE
                f.crystalReportViewer1.ReportSource = Crp;
                f.Show();
            }
        }
Пример #2
0
        private void BrnGraficas_Click(object sender, EventArgs e)
        {
            CrpGraficaxSexo Crp = new CrpGraficaxSexo();

            Crp.SetParameterValue("@CodEmpresa", CboEmpresa.SelectedValue);
            Crp.SetParameterValue("@FechaDesde", DtDesde.Value.ToShortDateString());
            Crp.SetParameterValue("@FechaHasta", DtHasta.Value.ToShortDateString());
            FrmVisualizarReporte f = new FrmVisualizarReporte();

            //SE VISUALIZA EL REPORTE
            f.crystalReportViewer1.ReportSource = Crp;
            f.Show();
        }
        private void PnlCertificado_Click(object sender, EventArgs e)
        {
            DataTable    TablaPaciente = new DataTable();
            ClsSqlServer NuevoSql      = new ClsSqlServer();

            NuevoSql.CadenaCnn = Historia_Clinica.Conexion.CadenaConexion.cadena();
            NuevoSql.Conectar();

            string Documento = DocumentoP;
            //SE REALIZAN LAS RESPECTIVAS COLUMNAS Y SE LLENAN LAS TABLAS CON LA INFORMACIÓN QUE SE REQUIERE PARA EL REPORTE
            string Query = "SELECT	dbo.Paciente.Pac_Nombre1+ ' ' + isnull(dbo.Paciente.Pac_Nombre2,'')                         "+
                           "		+' '+dbo.Paciente.Pac_Apellido1+ ' '+isnull(dbo.Paciente.Pac_Apellido2,'') As Nombres,      "+
                           "		dbo.Paciente.Pac_TipoIdentificacion, dbo.Paciente.Pac_TipoIdentificacion+' '+dbo.Paciente.Pac_Identificacion As Pac_Identificacion,                       "+
                           "		dbo.Paciente.Pac_FechaNacimiento, dbo.Genero.Gen_Descripcion,                               "+
                           "		dbo.Paciente.Pac_CodCiudad, dbo.Paciente.Pac_Direccion,                               "+
                           "		dbo.Paciente.Pac_CodNivelEducativo, dbo.Paciente.Pac_CodProfesion,Profesion.Prof_Descripcion,                             "+
                           "		dbo.TipoSangre.TipSan_Descripcion, dbo.Paciente.Pac_EstadoCivil,                            "+
                           "		dbo.EstadoCivil.EstCivil_Descripcion,Pac_Telefono                                           "+
                           "FROM	dbo.Paciente LEFT OUTER JOIN                                                                "+
                           "		dbo.EstadoCivil ON dbo.Paciente.Pac_EstadoCivil =                                           "+
                           "		dbo.EstadoCivil.EstCivil_Codigo LEFT OUTER JOIN                                             "+
                           "		dbo.TipoSangre ON dbo.Paciente.Pac_TipoSangre =                                             "+
                           "		dbo.TipoSangre.TipSan_Codigo LEFT OUTER JOIN                                                "+
                           "		dbo.Genero ON dbo.Paciente.Pac_CodGenero = dbo.Genero.Gen_Codigo inner join Profesion on Profesion.Prof_Codigo =    dbo.Paciente.Pac_CodProfesion                        "+
                           "WHERE	Pac_Identificacion='"+ Documento + "'";

            TablaPaciente = NuevoSql.LlenarTabla(Query);
            //FIN PACIENTE

            string NumeroEntrada = NumEntradaP;
            string Enfasis       = EnfasisP;
            string Fecha         = FechaP;
            string ConceptoTarea = ConceptoP;

            string examenes = "";
            string query    = "SELECT  dbo.Examen.Exam_Descripcion, dbo.EntradaHistoria.Entr_Numero, dbo.TipResultado.TipRes_Descripcion               " +
                              "FROM  dbo.ExamenPracticado INNER JOIN                                                                              " +
                              "dbo.Examen ON dbo.ExamenPracticado.ExaPrac_Examen_Codigo = dbo.Examen.Exam_Codigo INNER JOIN                       " +
                              "dbo.EntradaHistoria ON dbo.ExamenPracticado.ExaPrac_Entrada_Numero = dbo.EntradaHistoria.Entr_Numero INNER JOIN    " +
                              "dbo.TipResultado ON dbo.ExamenPracticado.ExaPrac_Resultado = dbo.TipResultado.TipRes_Codigo INNER JOIN             " +
                              "dbo.TipResultado AS TipResultado_1 ON dbo.ExamenPracticado.ExaPrac_Resultado = TipResultado_1.TipRes_Codigo WHERE dbo.EntradaHistoria.Entr_Numero=" + NumeroEntrada;
            DataTable TablaExamenes = new DataTable();

            TablaExamenes = NuevoSql.LlenarTabla(query);
            for (int i = 0; i < TablaExamenes.Rows.Count; i++)
            {
                string x = TablaExamenes.Rows[i]["Exam_Descripcion"].ToString() + " (" + TablaExamenes.Rows[i]["TipRes_Descripcion"].ToString() + ")";
                if (i == 0)
                {
                    examenes = x;
                }
                else
                {
                    examenes = examenes + "      " + x;
                }
            }

            //ENVIÓ DE PARAMETROS AL REPORTE
            string edad            = Convert.ToString(CalcularEdad(Convert.ToDateTime(TablaPaciente.Rows[0]["Pac_FechaNacimiento"]))) + " " + "Años";
            FrmVisualizarReporte f = new FrmVisualizarReporte();

            if (RdbCarta.Checked)
            {
                CrystalReport1 cry = new CrystalReport1();
                cry.SetParameterValue("NombreCompleto", TablaPaciente.Rows[0]["Nombres"]);
                cry.SetParameterValue("Documento", TablaPaciente.Rows[0]["Pac_Identificacion"]);
                cry.SetParameterValue("Edad", edad);
                cry.SetParameterValue("Genero", TablaPaciente.Rows[0]["Gen_Descripcion"]);
                cry.SetParameterValue("Telefono", TablaPaciente.Rows[0]["Pac_Telefono"].ToString());
                cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                if (examenes.Trim() == "")
                {
                    cry.SetParameterValue("ExamenesPracticados", "NO APLICA");
                }
                else
                {
                    cry.SetParameterValue("ExamenesPracticados", examenes);
                }

                cry.SetParameterValue("@NumeroEntrada", Convert.ToInt32(NumeroEntrada));
                cry.SetParameterValue("Enfasis", Enfasis);
                cry.SetParameterValue("FechaExamen", Fecha);
                if (ConceptoTarea == "")
                {
                    cry.SetParameterValue("DesAptitud", "");
                }
                else
                {
                    cry.SetParameterValue("DesAptitud", "CONCEPTO DE APTITUD PARA LA TAREA:");
                }
                cry.SetParameterValue("ConceptoTarea", ConceptoTarea);

                //PARA EL TIPO DE EXAMEN
                Query = "SELECT dbo.TipoExamen.TipoExam_Descripcion,                " +
                        "dbo.Concepto.Conc_Descripcion                              " +
                        "FROM   dbo.TipoExamen INNER JOIN                           " +
                        "dbo.EntradaHistoria ON dbo.TipoExamen.TipoExam_Codigo =    " +
                        "dbo.EntradaHistoria.Entr_TipoExamenCodigo INNER JOIN       " +
                        "dbo.Concepto ON dbo.EntradaHistoria.Entr_Concepto_Codigo = " +
                        "dbo.Concepto.Conc_Codigo where dbo.EntradaHistoria.Entr_Numero= " + NumeroEntrada;
                TablaPaciente = null;
                TablaPaciente = NuevoSql.LlenarTabla(Query);
                cry.SetParameterValue("TipoExamen", TablaPaciente.Rows[0]["TipoExam_Descripcion"].ToString());
                cry.SetParameterValue("Concepto", TablaPaciente.Rows[0]["Conc_Descripcion"].ToString());
                TablaPaciente = null;
                //PARA EL NOMBRE DE LA EMPRESA
                Query         = "SELECT Empresa.Empre_RazonSocial,Empresa.Empre_Nit, cargo.Carg_Descripcion as Ocup_Descripcion, InfOcu_Entrada_Numero FROM dbo.InformacionOcupacional inner join Empresa on InfOcu_CodEmpresa=Empresa.Empr_Codigo inner join cargo  on cargo.Carg_Codigo = InformacionOcupacional.InfOcu_CodOcupacion WHERE InfOcu_Entrada_Numero=" + NumeroEntrada;
                TablaPaciente = NuevoSql.LlenarTabla(Query);
                cry.SetParameterValue("NombreEmpresa", TablaPaciente.Rows[0]["Empre_RazonSocial"].ToString());
                cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                cry.SetParameterValue("nit", Configuracion.Nit);
                cry.SetParameterValue("tel", Configuracion.Telefono);
                cry.SetParameterValue("direccion", Configuracion.Direccion);
                cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                cry.SetParameterValue("nitempresa", TablaPaciente.Rows[0]["Empre_Nit"].ToString());
                cry.SetParameterValue("Cargo", TablaPaciente.Rows[0]["Ocup_Descripcion"]);

                Query = "SELECT	dbo.ARL.Arl_Codigo, dbo.ARL.Arl_Descripcion, " +
                        "dbo.EPS.Eps_Codigo, dbo.EPS.Eps_Descripcion,                              " +
                        "dbo.Paciente.Pac_Identificacion, dbo.Paciente.Pac_Nombre1,                " +
                        "dbo.Paciente.Pac_Nombre2, dbo.Paciente.Pac_Apellido1,                     " +
                        "dbo.Paciente.Pac_Apellido2, dbo.EntradaHistoria.Entr_IdPaciente,          " +
                        "dbo.EntradaHistoria.Entr_FechaEntrada, dbo.EntradaHistoria.Entr_Numero    " +
                        "FROM	dbo.EntradaHistoria RIGHT OUTER JOIN                               "+
                        "dbo.EPS INNER JOIN                                                        " +
                        "dbo.Paciente ON dbo.EPS.Eps_Codigo = dbo.Paciente.Pac_CodEPS INNER JOIN   " +
                        "dbo.ARL ON dbo.Paciente.Pac_CodARL = dbo.ARL.Arl_Codigo ON                " +
                        "dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion     " +
                        "AND dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion " +
                        "WHERE Pac_Identificacion='" + Documento + "'";
                TablaPaciente = null;
                TablaPaciente = NuevoSql.LlenarTabla(Query);

                if (TablaPaciente.Rows.Count > 0)
                {
                    cry.SetParameterValue("EPS", TablaPaciente.Rows[0]["Eps_Descripcion"]);
                    cry.SetParameterValue("ARL", TablaPaciente.Rows[0]["Arl_Descripcion"]);
                }
                else
                {
                    cry.SetParameterValue("EPS", "");
                    cry.SetParameterValue("ARL", "");
                }
                TablaPaciente = null;
                TablaExamenes = null;
                //SE VISUALIZA EL REPORTE
                f.crystalReportViewer1.ReportSource = cry;
                f.Show();
            }
            else
            {
                CrystalReport1Oficio cry = new CrystalReport1Oficio();
                cry.SetParameterValue("NombreCompleto", TablaPaciente.Rows[0]["Nombres"]);
                cry.SetParameterValue("Documento", TablaPaciente.Rows[0]["Pac_Identificacion"]);
                cry.SetParameterValue("Edad", edad);
                cry.SetParameterValue("Genero", TablaPaciente.Rows[0]["Gen_Descripcion"]);
                cry.SetParameterValue("Telefono", TablaPaciente.Rows[0]["Pac_Telefono"].ToString());
                cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                cry.SetParameterValue("nit", Configuracion.Nit);
                cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                if (examenes.Trim() == "")
                {
                    cry.SetParameterValue("ExamenesPracticados", "NO APLICA");
                }
                else
                {
                    cry.SetParameterValue("ExamenesPracticados", examenes);
                }

                cry.SetParameterValue("@NumeroEntrada", Convert.ToInt32(NumeroEntrada));
                cry.SetParameterValue("Enfasis", Enfasis);
                cry.SetParameterValue("FechaExamen", Fecha);
                if (ConceptoTarea == "")
                {
                    cry.SetParameterValue("DesAptitud", "");
                }
                else
                {
                    cry.SetParameterValue("DesAptitud", "CONCEPTO DE APTITUD PARA LA TAREA:");
                }
                cry.SetParameterValue("ConceptoTarea", ConceptoTarea);

                //PARA EL TIPO DE EXAMEN
                Query = "SELECT dbo.TipoExamen.TipoExam_Descripcion,                " +
                        "dbo.Concepto.Conc_Descripcion                              " +
                        "FROM   dbo.TipoExamen INNER JOIN                           " +
                        "dbo.EntradaHistoria ON dbo.TipoExamen.TipoExam_Codigo =    " +
                        "dbo.EntradaHistoria.Entr_TipoExamenCodigo INNER JOIN       " +
                        "dbo.Concepto ON dbo.EntradaHistoria.Entr_Concepto_Codigo = " +
                        "dbo.Concepto.Conc_Codigo where dbo.EntradaHistoria.Entr_Numero= " + NumeroEntrada;
                TablaPaciente = null;
                TablaPaciente = NuevoSql.LlenarTabla(Query);
                cry.SetParameterValue("TipoExamen", TablaPaciente.Rows[0]["TipoExam_Descripcion"].ToString());
                cry.SetParameterValue("Concepto", TablaPaciente.Rows[0]["Conc_Descripcion"].ToString());
                TablaPaciente = null;
                //PARA EL NOMBRE DE LA EMPRESA
                Query         = "SELECT Empresa.Empre_RazonSocial, Empresa.Empre_Nit, cargo.Carg_Descripcion as Ocup_Descripcion, InfOcu_Entrada_Numero FROM dbo.InformacionOcupacional inner join Empresa on InfOcu_CodEmpresa=Empresa.Empr_Codigo inner join cargo  on cargo.Carg_Codigo = InformacionOcupacional.InfOcu_CodOcupacion WHERE InfOcu_Entrada_Numero=" + NumeroEntrada;
                TablaPaciente = NuevoSql.LlenarTabla(Query);
                cry.SetParameterValue("NombreEmpresa", TablaPaciente.Rows[0]["Empre_RazonSocial"].ToString());
                cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                cry.SetParameterValue("nit", Configuracion.Nit);
                cry.SetParameterValue("tel", Configuracion.Telefono);
                cry.SetParameterValue("direccion", Configuracion.Direccion);
                cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                cry.SetParameterValue("nitempresa", TablaPaciente.Rows[0]["Empre_Nit"].ToString());
                cry.SetParameterValue("Cargo", TablaPaciente.Rows[0]["Ocup_Descripcion"]);

                Query = "SELECT	dbo.ARL.Arl_Codigo, dbo.ARL.Arl_Descripcion, " +
                        "dbo.EPS.Eps_Codigo, dbo.EPS.Eps_Descripcion,                              " +
                        "dbo.Paciente.Pac_Identificacion, dbo.Paciente.Pac_Nombre1,                " +
                        "dbo.Paciente.Pac_Nombre2, dbo.Paciente.Pac_Apellido1,                     " +
                        "dbo.Paciente.Pac_Apellido2, dbo.EntradaHistoria.Entr_IdPaciente,          " +
                        "dbo.EntradaHistoria.Entr_FechaEntrada, dbo.EntradaHistoria.Entr_Numero    " +
                        "FROM	dbo.EntradaHistoria RIGHT OUTER JOIN                               "+
                        "dbo.EPS INNER JOIN                                                        " +
                        "dbo.Paciente ON dbo.EPS.Eps_Codigo = dbo.Paciente.Pac_CodEPS INNER JOIN   " +
                        "dbo.ARL ON dbo.Paciente.Pac_CodARL = dbo.ARL.Arl_Codigo ON                " +
                        "dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion     " +
                        "AND dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion " +
                        "WHERE Pac_Identificacion='" + Documento + "'";
                TablaPaciente = null;
                TablaPaciente = NuevoSql.LlenarTabla(Query);
                if (TablaPaciente.Rows.Count > 0)
                {
                    cry.SetParameterValue("EPS", TablaPaciente.Rows[0]["Eps_Descripcion"]);
                    cry.SetParameterValue("ARL", TablaPaciente.Rows[0]["Arl_Descripcion"]);
                }
                else
                {
                    cry.SetParameterValue("EPS", "");
                    cry.SetParameterValue("ARL", "");
                }


                TablaPaciente = null;
                TablaExamenes = null;
                //SE VISUALIZA EL REPORTE
                f.crystalReportViewer1.ReportSource = cry;
                f.Show();
            }

            //}
            //}
        }
        private void DgvDatos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (RdbSinAtender.Checked)
            {
                //ABIRI FORMULADO DE HISTORIA CLINICA
                if (e.RowIndex > -1 && e.ColumnIndex == 3)
                {
                    FrnHistoriaClinica f = new FrnHistoriaClinica();
                    #region VARIABLES
                    string documento = DgvDatos.CurrentRow.Cells["DgvDatosColDocumento"].Value.ToString();
                    string edad      = DgvDatos.CurrentRow.Cells["DgvDatosColedad"].Value.ToString();
                    string sexo      = DgvDatos.CurrentRow.Cells["DgvDatosColSexo"].Value.ToString();
                    string fecha     = DgvDatos.CurrentRow.Cells["DgvDatosColFecha"].Value.ToString();
                    string entrada   = DgvDatos.CurrentRow.Cells["DgvDatosColEntrada"].Value.ToString();
                    string efasis    = DgvDatos.CurrentRow.Cells["DgvDatosColEnfasis"].Value.ToString();
                    string Nombres   = DgvDatos.CurrentRow.Cells["DgvDatosColNombres"].Value.ToString();
                    #endregion
                    IdPacientenAtencion = documento;
                    if (ConsultarPaciente())
                    {
                        #region PASAMOS LOS VALORES A LOS OBJETOS DEL FORMULARIO
                        //ConsultarPaciente();
                        f.LblDatos.Text     = "Tipo de Examen: " + entrada;
                        f.LblDatos1.Text    = "Enfasis: " + efasis;
                        f.LblDatos2.Text    = "Fecha : " + fecha.Substring(0, 10);
                        f.LblDatos3.Text    = "Sexo: " + sexo;
                        f.LblDatos4.Text    = "Edad: " + edad;
                        f.TxtNombre.Text    = Nombres;
                        f.TxtDocumento.Text = documento;
                        f.SooloVer          = false;
                        #endregion
                        f.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("El paciente ya fue atendido", "", MessageBoxButtons.OK);
                    }
                }
            }
            else
            {
                #region PARA ABRIR EL REPORTE Y EL FORMULARIO PARA VISUALIZAR LA INFORMACIÓN
                if (e.RowIndex > -1)
                {
                    if (e.ColumnIndex == DgvDatosColImprimir.Index)
                    {
                        string Documento = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColDocumento"].Value.ToString();
                        //SE REALIZAN LAS RESPECTIVAS COLUMNAS Y SE LLENAN LAS TABLAS CON LA INFORMACIÓN QUE SE REQUIERE PARA EL REPORTE
                        string Query = "SELECT	dbo.Paciente.Pac_Nombre1+ ' ' + isnull(dbo.Paciente.Pac_Nombre2,'')                         "+
                                       "		+' '+dbo.Paciente.Pac_Apellido1+ ' '+isnull(dbo.Paciente.Pac_Apellido2,'') As Nombres,      "+
                                       "		dbo.Paciente.Pac_TipoIdentificacion, dbo.Paciente.Pac_TipoIdentificacion+' '+dbo.Paciente.Pac_Identificacion As Pac_Identificacion,                       "+
                                       "		dbo.Paciente.Pac_FechaNacimiento, dbo.Genero.Gen_Descripcion,                               "+
                                       "		dbo.Paciente.Pac_CodCiudad, dbo.Paciente.Pac_Direccion,                               "+
                                       "		dbo.Paciente.Pac_CodNivelEducativo, dbo.Paciente.Pac_CodProfesion,Profesion.Prof_Descripcion,                             "+
                                       "		dbo.TipoSangre.TipSan_Descripcion, dbo.Paciente.Pac_EstadoCivil,                            "+
                                       "		dbo.EstadoCivil.EstCivil_Descripcion,Pac_Telefono                                           "+
                                       "FROM	dbo.Paciente LEFT OUTER JOIN                                                                "+
                                       "		dbo.EstadoCivil ON dbo.Paciente.Pac_EstadoCivil =                                           "+
                                       "		dbo.EstadoCivil.EstCivil_Codigo LEFT OUTER JOIN                                             "+
                                       "		dbo.TipoSangre ON dbo.Paciente.Pac_TipoSangre =                                             "+
                                       "		dbo.TipoSangre.TipSan_Codigo LEFT OUTER JOIN                                                "+
                                       "		dbo.Genero ON dbo.Paciente.Pac_CodGenero = dbo.Genero.Gen_Codigo inner join Profesion on Profesion.Prof_Codigo =    dbo.Paciente.Pac_CodProfesion                        "+
                                       "WHERE	Pac_Identificacion='"+ Documento + "'";
                        TablaPaciente = NuevoSql.LlenarTabla(Query);
                        //FIN PACIENTE

                        string NumeroEntrada = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                        string Enfasis       = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColEnfasis"].Value.ToString();
                        string Fecha         = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColFecha1"].Value.ToString();
                        string ConceptoTarea = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosconceptoAptitud"].Value.ToString();

                        string examenes = "";
                        string query    = "SELECT  dbo.Examen.Exam_Descripcion, dbo.EntradaHistoria.Entr_Numero, dbo.TipResultado.TipRes_Descripcion               " +
                                          "FROM  dbo.ExamenPracticado INNER JOIN                                                                              " +
                                          "dbo.Examen ON dbo.ExamenPracticado.ExaPrac_Examen_Codigo = dbo.Examen.Exam_Codigo INNER JOIN                       " +
                                          "dbo.EntradaHistoria ON dbo.ExamenPracticado.ExaPrac_Entrada_Numero = dbo.EntradaHistoria.Entr_Numero INNER JOIN    " +
                                          "dbo.TipResultado ON dbo.ExamenPracticado.ExaPrac_Resultado = dbo.TipResultado.TipRes_Codigo INNER JOIN             " +
                                          "dbo.TipResultado AS TipResultado_1 ON dbo.ExamenPracticado.ExaPrac_Resultado = TipResultado_1.TipRes_Codigo WHERE dbo.EntradaHistoria.Entr_Numero=" + NumeroEntrada;
                        DataTable TablaExamenes = new DataTable();
                        TablaExamenes = NuevoSql.LlenarTabla(query);
                        for (int i = 0; i < TablaExamenes.Rows.Count; i++)
                        {
                            string x = TablaExamenes.Rows[i]["Exam_Descripcion"].ToString() + " (" + TablaExamenes.Rows[i]["TipRes_Descripcion"].ToString() + ")";
                            if (i == 0)
                            {
                                examenes = x;
                            }
                            else
                            {
                                examenes = examenes + "      " + x;
                            }
                        }
                        //ENVIÓ DE PARAMETROS AL REPORTE
                        string edad              = Convert.ToString(CalcularEdad(Convert.ToDateTime(TablaPaciente.Rows[0]["Pac_FechaNacimiento"]))) + " " + "Años";
                        FrmVisualizarReporte f   = new FrmVisualizarReporte();
                        CrystalReport1       cry = new CrystalReport1();
                        string documento         = TablaPaciente.Rows[0]["Pac_Identificacion"].ToString();
                        cry.SetParameterValue("NombreCompleto", TablaPaciente.Rows[0]["Nombres"]);
                        cry.SetParameterValue("Documento", TablaPaciente.Rows[0]["Pac_Identificacion"]);
                        cry.SetParameterValue("Edad", edad);
                        cry.SetParameterValue("Genero", TablaPaciente.Rows[0]["Gen_Descripcion"]);
                        cry.SetParameterValue("Telefono", TablaPaciente.Rows[0]["Pac_Telefono"].ToString());
                        cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                        cry.SetParameterValue("nit", Configuracion.Nit);
                        cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                        if (examenes.Trim() == "")
                        {
                            cry.SetParameterValue("ExamenesPracticados", "NO APLICA");
                        }
                        else
                        {
                            cry.SetParameterValue("ExamenesPracticados", examenes);
                        }

                        cry.SetParameterValue("@NumeroEntrada", Convert.ToInt32(NumeroEntrada));
                        cry.SetParameterValue("Enfasis", Enfasis);
                        cry.SetParameterValue("FechaExamen", Fecha);
                        if (ConceptoTarea == "")
                        {
                            cry.SetParameterValue("DesAptitud", "");
                        }
                        else
                        {
                            cry.SetParameterValue("DesAptitud", "CONCEPTO DE APTITUD PARA LA TAREA:");
                        }
                        cry.SetParameterValue("ConceptoTarea", ConceptoTarea);

                        //PARA EL TIPO DE EXAMEN
                        Query = "SELECT dbo.TipoExamen.TipoExam_Descripcion,                " +
                                "dbo.Concepto.Conc_Descripcion                              " +
                                "FROM   dbo.TipoExamen INNER JOIN                           " +
                                "dbo.EntradaHistoria ON dbo.TipoExamen.TipoExam_Codigo =    " +
                                "dbo.EntradaHistoria.Entr_TipoExamenCodigo INNER JOIN       " +
                                "dbo.Concepto ON dbo.EntradaHistoria.Entr_Concepto_Codigo = " +
                                "dbo.Concepto.Conc_Codigo where dbo.EntradaHistoria.Entr_Numero= " + NumeroEntrada;
                        TablaPaciente = null;
                        TablaPaciente = NuevoSql.LlenarTabla(Query);
                        cry.SetParameterValue("TipoExamen", TablaPaciente.Rows[0]["TipoExam_Descripcion"].ToString());
                        cry.SetParameterValue("Concepto", TablaPaciente.Rows[0]["Conc_Descripcion"].ToString());
                        TablaPaciente = null;
                        //PARA EL NOMBRE DE LA EMPRESA
                        Query         = "SELECT Empresa.Empre_RazonSocial,Empresa.Empre_Nit, cargo.Carg_Descripcion as Ocup_Descripcion, InfOcu_Entrada_Numero FROM dbo.InformacionOcupacional inner join Empresa on InfOcu_CodEmpresa=Empresa.Empr_Codigo inner join cargo  on cargo.Carg_Codigo = InformacionOcupacional.InfOcu_CodOcupacion WHERE InfOcu_Entrada_Numero=" + NumeroEntrada;
                        TablaPaciente = NuevoSql.LlenarTabla(Query);
                        cry.SetParameterValue("NombreEmpresa", TablaPaciente.Rows[0]["Empre_RazonSocial"].ToString());
                        cry.SetParameterValue("nitempresa", TablaPaciente.Rows[0]["Empre_Nit"].ToString());
                        cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                        cry.SetParameterValue("nit", Configuracion.Nit);
                        cry.SetParameterValue("tel", Configuracion.Telefono);
                        cry.SetParameterValue("direccion", Configuracion.Direccion);
                        cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                        cry.SetParameterValue("Cargo", TablaPaciente.Rows[0]["Ocup_Descripcion"]);

                        Query = "SELECT	dbo.ARL.Arl_Codigo, dbo.ARL.Arl_Descripcion, " +
                                "dbo.EPS.Eps_Codigo, dbo.EPS.Eps_Descripcion,                              " +
                                "dbo.Paciente.Pac_Identificacion, dbo.Paciente.Pac_Nombre1,                " +
                                "dbo.Paciente.Pac_Nombre2, dbo.Paciente.Pac_Apellido1,                     " +
                                "dbo.Paciente.Pac_Apellido2, dbo.EntradaHistoria.Entr_IdPaciente,          " +
                                "dbo.EntradaHistoria.Entr_FechaEntrada, dbo.EntradaHistoria.Entr_Numero    " +
                                "FROM	dbo.EntradaHistoria RIGHT OUTER JOIN                               "+
                                "dbo.EPS INNER JOIN                                                        " +
                                "dbo.Paciente ON dbo.EPS.Eps_Codigo = dbo.Paciente.Pac_CodEPS INNER JOIN   " +
                                "dbo.ARL ON dbo.Paciente.Pac_CodARL = dbo.ARL.Arl_Codigo ON                " +
                                "dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion     " +
                                "AND dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion " +
                                "WHERE Pac_Identificacion='" + Documento + "'";
                        TablaPaciente = null;
                        TablaPaciente = NuevoSql.LlenarTabla(Query);
                        if (TablaPaciente.Rows.Count > 0)
                        {
                            cry.SetParameterValue("EPS", TablaPaciente.Rows[0]["Eps_Descripcion"]);
                            cry.SetParameterValue("ARL", TablaPaciente.Rows[0]["Arl_Descripcion"]);
                        }
                        else
                        {
                            cry.SetParameterValue("EPS", "");
                            cry.SetParameterValue("ARL", "");
                        }


                        TablaPaciente = null;
                        TablaExamenes = null;
                        //SE VISUALIZA EL REPORTE
                        f.crystalReportViewer1.ReportSource = cry;
                        f.Show();
                    }
                }
                #endregion

                #region PARA ARIR FORMULARIO DE HISTORIA PARA VER LA HISTORIA DEL PACIENTE
                if (e.RowIndex > -1)
                {
                    if (e.ColumnIndex == DgvDatosColatendido.Index)
                    {
                        string documento      = DgvDatos.CurrentRow.Cells["DgvDatosColDocumento"].Value.ToString();
                        string NumeroEntrada  = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                        string Enfasis        = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColEnfasis"].Value.ToString();
                        string Fecha          = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColFecha1"].Value.ToString();
                        string ConceptoTarea  = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosconceptoAptitud"].Value.ToString();
                        FrmOpcionesImprimir f = new FrmOpcionesImprimir();

                        f.NumeroAtencion = Convert.ToInt32(DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString());
                        string Nombres = DgvDatos.CurrentRow.Cells["DgvDatosColNombres"].Value.ToString();
                        f.LblNombre.Text = Nombres;
                        f.DocumentoP     = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColDocumento"].Value.ToString();
                        f.NumEntradaP    = NumeroEntrada;
                        f.EnfasisP       = Enfasis;
                        f.FechaP         = Fecha;
                        f.documento      = documento;

                        f.ConceptoP = ConceptoTarea;

                        f.ShowDialog();
                    }

                    if (e.ColumnIndex == DgvDatosColDocumento.Index || e.ColumnIndex == DgvDatosColNombres.Index)
                    {
                        if (LblMensaje.Text == "HISTORIA MÉDICA")
                        {
                            string             paciente = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColDocumento"].Value.ToString();
                            FrnHistoriaClinica f        = new FrnHistoriaClinica();
                            f.LblEntrada.Visible = true;
                            f.LblEntrada.Text    = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                            f.TxtDocumento.Text  = paciente;
                            if (DgvDatos.Rows[e.RowIndex].Cells["Column1"].Value.ToString() == "False")
                            {
                                f.SooloVer = true;
                                //f.BuscarTodo();
                                f.BtnCerrarHistoria.Visible  = true;
                                f.BtnGuardarHistoria.Visible = true;
                                f.BtnCerrarHistoria.Visible  = true;
                                f.LblGuardarCerra.Visible    = true;
                                f.LblGuardar.Visible         = true;
                                f.TxtDocumento.BackColor     = Color.SteelBlue;
                            }
                            else
                            {
                                f.SooloVer = true;
                                //f.BuscarTodo();
                                f.TxtDocumento.ReadOnly      = true;
                                f.BtnGuardarHistoria.Visible = false;
                                f.BtnCerrarHistoria.Visible  = false;
                                f.LblGuardarCerra.Visible    = false;
                                f.LblGuardar.Visible         = false;
                            }
                            if (LblMensaje.Text == "CETIFICADOS Y HISTORIAS")
                            {
                                f.TxtDocumento.ReadOnly      = true;
                                f.BtnGuardarHistoria.Visible = false;
                                f.BtnCerrarHistoria.Visible  = false;
                                f.LblGuardarCerra.Visible    = false;
                                f.LblGuardar.Visible         = false;
                            }
                            string documento = DgvDatos.CurrentRow.Cells["DgvDatosColDocumento"].Value.ToString();
                            string edad      = DgvDatos.CurrentRow.Cells["DgvDatosColedad"].Value.ToString();
                            string sexo      = DgvDatos.CurrentRow.Cells["DgvDatosColSexo"].Value.ToString();
                            string fecha     = DgvDatos.CurrentRow.Cells["DgvDatosColFecha"].Value.ToString();
                            string entrada   = DgvDatos.CurrentRow.Cells["DgvDatosColEntrada"].Value.ToString();
                            string efasis    = DgvDatos.CurrentRow.Cells["DgvDatosColEnfasis"].Value.ToString();

                            f.LblDatos.Text  = "Tipo de Examen: " + entrada;
                            f.LblDatos1.Text = "Enfasis: " + efasis;
                            f.LblDatos2.Text = "Fecha : " + fecha.Substring(0, 10);
                            f.LblDatos3.Text = "Sexo: " + sexo;
                            f.LblDatos4.Text = "Edad: " + edad;

                            f.ShowDialog();
                        }
                        else
                        {
                            if (DgvDatos.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.SteelBlue)
                            {
                                if (MessageBox.Show("¿Desea ver y adjuntar examenes?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    string          documento      = DgvDatos.CurrentRow.Cells["DgvDatosColDocumento"].Value.ToString();
                                    string          Nombres        = DgvDatos.CurrentRow.Cells["DgvDatosColNombres"].Value.ToString();
                                    string          NumeroAtencion = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                                    FrmVerPacientes f = new FrmVerPacientes();
                                    f.LblNombrePaciente.Text = Nombres;
                                    f.LblNumeroAtencion.Text = NumeroAtencion;
                                    f.txtidentificacion.Text = documento;
                                    f.ShowDialog();
                                }
                            }
                        }
                    }
                }
                #endregion
            }
        }
Пример #5
0
        private void DgvDatos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //try
            //{
            DataTable TablaPaciente = new DataTable();

            //SE VERIFIVA QUE SE HAYA SELECCIONADO UNA COLUMNA
            if (e.ColumnIndex > 0)
            {
                //PREGUNTAMOS QUE SERA LA COLUMNA DE IMPRIMIR
                if (DgvDatos.Columns[e.ColumnIndex].HeaderText == "********")
                {
                    string Documento = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColDocumento"].Value.ToString();
                    //SE REALIZAN LAS RESPECTIVAS COLUMNAS Y SE LLENAN LAS TABLAS CON LA INFORMACIÓN QUE SE REQUIERE PARA EL REPORTE
                    string Query = "SELECT	dbo.Paciente.Pac_Nombre1+ ' ' + isnull(dbo.Paciente.Pac_Nombre2,'')                         "+
                                   "		+' '+dbo.Paciente.Pac_Apellido1+ ' '+isnull(dbo.Paciente.Pac_Apellido2,'') As Nombres,      "+
                                   "		dbo.Paciente.Pac_TipoIdentificacion, dbo.Paciente.Pac_TipoIdentificacion+' '+dbo.Paciente.Pac_Identificacion As Pac_Identificacion,                       "+
                                   "		dbo.Paciente.Pac_FechaNacimiento, dbo.Genero.Gen_Descripcion,                               "+
                                   "		dbo.Paciente.Pac_LugarNacimiento, dbo.Paciente.Pac_Direccion,                               "+
                                   "		dbo.Paciente.Pac_NivelEducacion, dbo.Paciente.Pac_Profesion_Codigo,                         "+
                                   "		dbo.TipoSangre.TipSan_Descripcion, dbo.Paciente.Pac_EstadoCivil,                            "+
                                   "		dbo.EstadoCivil.EstCivil_Descripcion,Pac_Telefono                                           "+
                                   "FROM	dbo.Paciente LEFT OUTER JOIN                                                                "+
                                   "		dbo.EstadoCivil ON dbo.Paciente.Pac_EstadoCivil =                                           "+
                                   "		dbo.EstadoCivil.EstCivil_Codigo LEFT OUTER JOIN                                             "+
                                   "		dbo.TipoSangre ON dbo.Paciente.Pac_TipoSangre =                                             "+
                                   "		dbo.TipoSangre.TipSan_Codigo LEFT OUTER JOIN                                                "+
                                   "		dbo.Genero ON dbo.Paciente.Pac_Genero_Codigo = dbo.Genero.Gen_Codigo                        "+
                                   "WHERE	Pac_Identificacion='"+ Documento + "'";
                    TablaPaciente = NuevoSql.LlenarTabla(Query);
                    //FIN PACIENTE

                    string NumeroEntrada = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                    string Enfasis       = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColEnfasis"].Value.ToString();
                    string Fecha         = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColFecha"].Value.ToString();
                    string examenes      = "";
                    string query         = "SELECT  dbo.Examen.Exam_Descripcion, dbo.EntradaHistoria.Entr_Numero, dbo.TipResultado.TipRes_Descripcion               " +
                                           "FROM  dbo.ExamenPracticado INNER JOIN                                                                              " +
                                           "dbo.Examen ON dbo.ExamenPracticado.ExaPrac_Examen_Codigo = dbo.Examen.Exam_Codigo INNER JOIN                       " +
                                           "dbo.EntradaHistoria ON dbo.ExamenPracticado.ExaPrac_Entrada_Numero = dbo.EntradaHistoria.Entr_Numero INNER JOIN    " +
                                           "dbo.TipResultado ON dbo.ExamenPracticado.ExaPrac_Resultado = dbo.TipResultado.TipRes_Codigo INNER JOIN             " +
                                           "dbo.TipResultado AS TipResultado_1 ON dbo.ExamenPracticado.ExaPrac_Resultado = TipResultado_1.TipRes_Codigo WHERE dbo.EntradaHistoria.Entr_Numero=" + NumeroEntrada;
                    DataTable TablaExamenes = new DataTable();
                    TablaExamenes = NuevoSql.LlenarTabla(query);
                    for (int i = 0; i < TablaExamenes.Rows.Count; i++)
                    {
                        string x = TablaExamenes.Rows[i]["Exam_Descripcion"].ToString() + " (" + TablaExamenes.Rows[i]["TipRes_Descripcion"].ToString() + ")";
                        if (i == 0)
                        {
                            examenes = x;
                        }
                        else
                        {
                            examenes = examenes + "      " + x;
                        }
                    }
                    //ENVIÓ DE PARAMETROS AL REPORTE
                    string edad              = Convert.ToString(CalcularEdad(Convert.ToDateTime(TablaPaciente.Rows[0]["Pac_FechaNacimiento"]))) + " " + "Años";
                    FrmVisualizarReporte f   = new FrmVisualizarReporte();
                    CrystalReport1       cry = new CrystalReport1();
                    cry.SetParameterValue("NombreCompleto", TablaPaciente.Rows[0]["Nombres"]);
                    cry.SetParameterValue("Cargo", TablaPaciente.Rows[0]["Pac_Profesion_Codigo"]);
                    cry.SetParameterValue("Documento", TablaPaciente.Rows[0]["Pac_Identificacion"]);
                    cry.SetParameterValue("Edad", edad);
                    cry.SetParameterValue("Genero", TablaPaciente.Rows[0]["Gen_Descripcion"]);
                    cry.SetParameterValue("Telefono", TablaPaciente.Rows[0]["Pac_Telefono"].ToString());
                    cry.SetParameterValue("EPS", "NOMBRE DE LA EPS");
                    cry.SetParameterValue("ARL", "NOMBRE DE LA ARL");
                    cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                    cry.SetParameterValue("nit", Configuracion.Nit);
                    cry.SetParameterValue("piepagina", Configuracion.PiePagina);
                    if (examenes.Trim() == "")
                    {
                        cry.SetParameterValue("ExamenesPracticados", "NO APLICA");
                    }
                    else
                    {
                        cry.SetParameterValue("ExamenesPracticados", examenes);
                    }

                    cry.SetParameterValue("@NumeroEntrada", Convert.ToInt32(NumeroEntrada));
                    cry.SetParameterValue("Enfasis", Enfasis);
                    cry.SetParameterValue("FechaExamen", Fecha);
                    //cry.DataSourceConnections = NuevoSql.conexion;

                    //PARA EL TIPO DE EXAMEN
                    Query = "SELECT dbo.TipoExamen.TipoExam_Descripcion,                " +
                            "dbo.Concepto.Conc_Descripcion                              " +
                            "FROM   dbo.TipoExamen INNER JOIN                           " +
                            "dbo.EntradaHistoria ON dbo.TipoExamen.TipoExam_Codigo =    " +
                            "dbo.EntradaHistoria.Entr_TipoExamenCodigo INNER JOIN       " +
                            "dbo.Concepto ON dbo.EntradaHistoria.Entr_Concepto_Codigo = " +
                            "dbo.Concepto.Conc_Codigo where dbo.EntradaHistoria.Entr_Numero= " + NumeroEntrada;
                    TablaPaciente = null;
                    TablaPaciente = NuevoSql.LlenarTabla(Query);
                    cry.SetParameterValue("TipoExamen", TablaPaciente.Rows[0]["TipoExam_Descripcion"].ToString());
                    cry.SetParameterValue("Concepto", TablaPaciente.Rows[0]["Conc_Descripcion"].ToString());
                    TablaPaciente = null;
                    //PARA EL NOMBRE DE LA EMPRESA
                    Query         = "SELECT InfOcu_Empresa, InfOcu_Entrada_Numero FROM dbo.InformacionOcupacional WHERE InfOcu_Entrada_Numero=" + NumeroEntrada;
                    TablaPaciente = NuevoSql.LlenarTabla(Query);
                    cry.SetParameterValue("NombreEmpresa", TablaPaciente.Rows[0]["InfOcu_Empresa"].ToString());
                    //cry.SetParameterValue("nitempresa", TablaPaciente.Rows[0]["InfOcu_Nit"].ToString());
                    cry.SetParameterValue("Ciudad", Configuracion.LugarExamen);
                    cry.SetParameterValue("nit", Configuracion.Nit);
                    cry.SetParameterValue("tel", Configuracion.Telefono);
                    cry.SetParameterValue("direccion", Configuracion.Direccion);
                    cry.SetParameterValue("piepagina", Configuracion.PiePagina);

                    Query = "SELECT	dbo.ARL.Arl_Codigo, dbo.ARL.Arl_Descripcion, " +
                            "dbo.EPS.Eps_Codigo, dbo.EPS.Eps_Descripcion,                              " +
                            "dbo.Paciente.Pac_Identificacion, dbo.Paciente.Pac_Nombre1,                " +
                            "dbo.Paciente.Pac_Nombre2, dbo.Paciente.Pac_Apellido1,                     " +
                            "dbo.Paciente.Pac_Apellido2, dbo.EntradaHistoria.Entr_IdPaciente,          " +
                            "dbo.EntradaHistoria.Entr_FechaEntrada, dbo.EntradaHistoria.Entr_Numero    " +
                            "FROM	dbo.EntradaHistoria RIGHT OUTER JOIN                               "+
                            "dbo.EPS INNER JOIN                                                        " +
                            "dbo.Paciente ON dbo.EPS.Eps_Codigo = dbo.Paciente.Pac_CodEPS INNER JOIN   " +
                            "dbo.ARL ON dbo.Paciente.Pac_CodARL = dbo.ARL.Arl_Codigo ON                " +
                            "dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion     " +
                            "AND dbo.EntradaHistoria.Entr_IdPaciente = dbo.Paciente.Pac_Identificacion " +
                            "WHERE Pac_Identificacion='" + Documento + "'";
                    TablaPaciente = null;
                    TablaPaciente = NuevoSql.LlenarTabla(Query);
                    if (TablaPaciente.Rows.Count > 0)
                    {
                        cry.SetParameterValue("EPS", TablaPaciente.Rows[0]["Eps_Descripcion"]);
                        cry.SetParameterValue("ARL", TablaPaciente.Rows[0]["Arl_Descripcion"]);
                    }
                    else
                    {
                        cry.SetParameterValue("EPS", "");
                        cry.SetParameterValue("ARL", "");
                    }

                    //cry.DataSourceConnections[0].SetConnection("192.168.1.10", "2019";
                    //cry.Load()
                    TablaPaciente = null;
                    TablaExamenes = null;
                    //SE VISUALIZA EL REPORTE
                    f.crystalReportViewer1.ReportSource = cry;
                    f.Show();
                }
            }

            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("No se puede generar el reporte","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            //}
            try
            {
                if (DgvDatos.Columns[e.ColumnIndex].HeaderText == "-----")
                {
                    HistoriaPaciente f = new HistoriaPaciente();
                    f.Nhistoria         = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColNumeroHistoria"].Value.ToString();
                    f.TxtDocumento.Text = DgvDatos.Rows[e.RowIndex].Cells["DgvDatosColDocumento"].Value.ToString();
                    f.Show();
                }
            }
            catch (Exception)
            { }
        }