Ejemplo n.º 1
0
        private void GenerarReporte()
        {
            ///var CerifImputado = SelectIngreso.IMPUTADO;
            ///



            #region Iniciliza el entorno para mostrar el reporte al usuario
            System.Windows.Application.Current.Dispatcher.Invoke((Action)(delegate
            {
                var ReporteView_ = (ReportViewer)WindowControl.FindName("Report");

                //PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.OSCURECER_FONDO);
                //View.Owner = PopUpsViewModels.MainWindow;
                //View.Closed += (s, e) => { PopUpsViewModels.ClosePopUp(PopUpsViewModels.TipoPopUp.OSCURECER_FONDO); };


                //View.Show();
                #endregion

                #region Se forma el encabezado del reporte
                var Encabezado = new cEncabezado();
                Encabezado.TituloUno = "GOBIERNO DEL ESTADO  DE BAJA CALIFORNIA";
                Encabezado.TituloDos = "SUBSECRETARÍA DEL SISTEMA ESTATAL PENITENCIARIO";
                Encabezado.NombreReporte = "SOLICITUDES DE ATENCIÓN POR ESTATUS";
                Encabezado.ImagenIzquierda = Parametro.LOGO_ESTADO;
                Encabezado.ImagenFondo = Parametro.REPORTE_LOGO2;

                #endregion

                #region Llenar Informacion

                var LstDatosBusqueda = BuscarResultado();
                int Count = LstDatosBusqueda.Count();

                var LstDatosFiltro = Count > 0 ? LstDatosBusqueda.OrderBy(o => o.ID_ANIO).ThenBy(then => then.ID_IMPUTADO).ThenBy(then => then.ATENCION_SOLICITUD.SOLICITUD_FEC) : null;

                var listaDatosReporte = new List <cReporteSolicitudPorEstatus>();
                if (Count == 0)
                {
                    ReporteView_.Clear();
                    StaticSourcesViewModel.Mensaje("Aviso", "La Busqueda no contiene Información", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION, 5);
                }
                else
                {
                    int cant = 0;


                    foreach (var itemAtencionIngreso in LstDatosFiltro.Select(s => new { s.ID_IMPUTADO, s.ID_ANIO, s.ID_CENTRO, s.ID_INGRESO, s.ATENCION_SOLICITUD.ACTIVIDAD, s.INGRESO.IMPUTADO.PATERNO, s.INGRESO.IMPUTADO.MATERNO, s.INGRESO.IMPUTADO.NOMBRE, s.ATENCION_SOLICITUD.SOLICITUD_FEC, s.ESTATUS, AREA_TECNICA_DESCR = s.ATENCION_SOLICITUD.AREA_TECNICA.DESCR, FECHA_SOLICITUD = (DateTime?)s.ATENCION_SOLICITUD.SOLICITUD_FEC, s.ID_ATENCION }))
                    {
                        //-----------------------------------------VERIFICA SI TIENE SOLICITUD_CITA--------------------------------------------------
                        var querySolCitas = AtencionCitaControlador.ObtenerTodo().Where(w => w.ID_ANIO == itemAtencionIngreso.ID_ANIO && w.ID_CENTRO == itemAtencionIngreso.ID_CENTRO && w.ID_IMPUTADO == itemAtencionIngreso.ID_IMPUTADO && w.ID_INGRESO == itemAtencionIngreso.ID_INGRESO && w.ID_ATENCION == itemAtencionIngreso.ID_ATENCION).ToList();
                        cant++;
                        var DatosReporte = new cReporteSolicitudPorEstatus();
                        // *************Se Filtra Agrupacion ESTATUS-AREA TECNICA **********
                        string ESTAUS = itemAtencionIngreso.ESTATUS == 1 ? "ATENDIDA" : "NO ATENDIDA";
                        DatosReporte.GrupoEstatus_AreaTecn = ESTAUS + "-" + itemAtencionIngreso.AREA_TECNICA_DESCR;
                        DatosReporte.Estado = SelectEstatus == -1 ? "TODOS" : LstEstatus.Where(W => W.ID_ESTATUS == SelectEstatus).FirstOrDefault().DESCR;
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append(itemAtencionIngreso.ID_ANIO.ToString());
                        sb.Append("/");
                        sb.AppendLine(itemAtencionIngreso.ID_IMPUTADO.ToString());
                        DatosReporte.Anio = sb.ToString();
                        //itemAtencionIngreso.ID_ANIO.ToString() + "/" + itemAtencionIngreso.ID_IMPUTADO.ToString();
                        DatosReporte.Actividad = itemAtencionIngreso.ACTIVIDAD;
                        string Paterno = !string.IsNullOrEmpty(itemAtencionIngreso.PATERNO) ? itemAtencionIngreso.PATERNO.Trim() : "";
                        string Materno = !string.IsNullOrEmpty(itemAtencionIngreso.MATERNO) ? itemAtencionIngreso.MATERNO.Trim() : "";
                        string Nombre = !string.IsNullOrEmpty(itemAtencionIngreso.NOMBRE) ? itemAtencionIngreso.NOMBRE.Trim() : "";
                        DatosReporte.NombreImputado = Paterno + " " + Paterno + " " + Materno;
                        DatosReporte.FechaCita = "";
                        DatosReporte.FechaSolicitud = itemAtencionIngreso.SOLICITUD_FEC != null ? itemAtencionIngreso.SOLICITUD_FEC.Value.ToShortDateString() : "";
                        // var datoscita = AtencionCitaControlador.ObtenerTodo().Where(w => w.ID_ANIO == itemAtencionIngreso.ID_ANIO && w.ID_CENTRO == itemAtencionIngreso.ID_CENTRO && w.ID_IMPUTADO == itemAtencionIngreso.ID_IMPUTADO && w.ID_INGRESO == itemAtencionIngreso.ID_INGRESO && w.ID_ATENCION == itemAtencionIngreso.ID_ATENCION);


                        DatosReporte.Total = Count.ToString();

                        if (querySolCitas.Count() > 0 && itemAtencionIngreso.ESTATUS == 1)//SI TIENE ESTATUS 1 busca la fecha ya que ya tiene cita
                        {
                            DateTime?FECHA_CITA = querySolCitas.FirstOrDefault().CITA_FECHA_HORA;
                            DatosReporte.FechaCita = FECHA_CITA != null ? FECHA_CITA.Value.ToShortDateString() : "";
                        }
                        listaDatosReporte.Add(DatosReporte);
                    }
                    // ------------------TOTAL ------------------------------------

                    if (cant == 0)
                    {
                        ReporteView_.Clear();
                        StaticSourcesViewModel.Mensaje("Aviso", "La Busqueda no contiene Información", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION, 5);
                    }
                    else
                    {
                        #region Inicializacion de reporte


                        ReporteView_.LocalReport.ReportPath = "Reportes/rSolicitudesAtencionPorEstatus.rdlc";
                        ReporteView_.LocalReport.DataSources.Clear();
                        #endregion


                        #region DATOS REPORTE TABLA

                        Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource();
                        rds.Name = "DataSet1";
                        rds.Value = listaDatosReporte;
                        ReporteView_.LocalReport.DataSources.Add(rds);
                        #endregion

                        #region DATOS REPORTE ENCABEZADO REPORTE
                        var dsEncabezado = new List <cEncabezado>();
                        dsEncabezado.Add(Encabezado);
                        Microsoft.Reporting.WinForms.ReportDataSource rds2 = new Microsoft.Reporting.WinForms.ReportDataSource();
                        rds2.Name = "DataSet2";
                        rds2.Value = dsEncabezado;
                        ReporteView_.LocalReport.DataSources.Add(rds2);
                        #endregion



                        ReporteView_.RefreshReport();
                    }
                    #endregion
                }
            }));
        }
Ejemplo n.º 2
0
        private void ImprimirRecetaMedica()
        {
            try
            {
                if (SelectedNotaMedica == null)
                {
                    return;
                }

                ReportesView View = new ReportesView();
                PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.OSCURECER_FONDO);
                View.Owner   = PopUpsViewModels.MainWindow;
                View.Closed += (s, e) => { PopUpsViewModels.ClosePopUp(PopUpsViewModels.TipoPopUp.OSCURECER_FONDO); };

                View.Show();

                var _UsuarioActual = new SSP.Controlador.Catalogo.Justicia.cUsuario().GetData(x => x.ID_USUARIO.Trim() == GlobalVar.gUsr).FirstOrDefault();
                cRecetaMedicaReporte DatosReporte = new cRecetaMedicaReporte()
                {
                    Edad           = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO != null ? new Fechas().CalculaEdad(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.NACIMIENTO_FECHA).ToString() : string.Empty : string.Empty : string.Empty,
                    Fecha          = Fechas.GetFechaDateServer.ToString("dd/MM/yyyy"),
                    NoExpediente   = string.Format("{0} / {1}", SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.ID_ANIO.HasValue ? SelectedNotaMedica.ATENCION_MEDICA.ID_ANIO.Value.ToString() : string.Empty : string.Empty, SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.ID_IMPUTADO.HasValue ? SelectedNotaMedica.ATENCION_MEDICA.ID_IMPUTADO.Value.ToString() : string.Empty : string.Empty),
                    NombrePaciente = string.Format("{0} {1} {2}",
                                                   SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.NOMBRE) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.NOMBRE.Trim() : string.Empty : string.Empty : string.Empty : string.Empty,
                                                   SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.PATERNO) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.PATERNO.Trim() : string.Empty : string.Empty : string.Empty : string.Empty,
                                                   SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.MATERNO) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.IMPUTADO.MATERNO.Trim() : string.Empty : string.Empty : string.Empty : string.Empty),
                    Estancia = string.Format("{0}-{1}{2}-{3}",
                                             SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR.EDIFICIO != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR.EDIFICIO.DESCR) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR.EDIFICIO.DESCR.Trim() : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty,
                                             SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR.DESCR) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.SECTOR.DESCR.Trim() : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty,
                                             SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.ID_CELDA) ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.CAMA.CELDA.ID_CELDA.Trim() : string.Empty : string.Empty : string.Empty : string.Empty,
                                             SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO != null ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.ID_UB_CAMA.HasValue ? SelectedNotaMedica.ATENCION_MEDICA.INGRESO.ID_UB_CAMA.Value.ToString() : string.Empty : string.Empty : string.Empty),
                    FC       = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.FRECUENCIA_CARDIAC) ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.FRECUENCIA_CARDIAC.Trim() : string.Empty : string.Empty : string.Empty,
                    FR       = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.FRECUENCIA_RESPIRA) ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.FRECUENCIA_RESPIRA.Trim() : string.Empty : string.Empty : string.Empty,
                    TA       = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.TENSION_ARTERIAL) ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.TENSION_ARTERIAL.Trim() : string.Empty : string.Empty : string.Empty,
                    T        = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.TEMPERATURA) ? SelectedNotaMedica.ATENCION_MEDICA.NOTA_SIGNOS_VITALES.TEMPERATURA.Trim() : string.Empty : string.Empty : string.Empty,
                    Servicio = SelectedNotaMedica.ATENCION_MEDICA != null ? SelectedNotaMedica.ATENCION_MEDICA.ATENCION_SERVICIO != null ? !string.IsNullOrEmpty(SelectedNotaMedica.ATENCION_MEDICA.ATENCION_SERVICIO.DESCR) ? SelectedNotaMedica.ATENCION_MEDICA.ATENCION_SERVICIO.DESCR.Trim() : string.Empty : string.Empty : string.Empty,
                    Generico = _UsuarioActual != null?string.Format("{0} {1} {2}",
                                                                    _UsuarioActual.EMPLEADO != null?_UsuarioActual.EMPLEADO.PERSONA != null? !string.IsNullOrEmpty(_UsuarioActual.EMPLEADO.PERSONA.NOMBRE)?_UsuarioActual.EMPLEADO.PERSONA.NOMBRE.Trim() : string.Empty : string.Empty : string.Empty,
                                                                        _UsuarioActual.EMPLEADO != null?_UsuarioActual.EMPLEADO.PERSONA != null? !string.IsNullOrEmpty(_UsuarioActual.EMPLEADO.PERSONA.PATERNO)?_UsuarioActual.EMPLEADO.PERSONA.PATERNO.Trim() : string.Empty : string.Empty : string.Empty,
                                                                            _UsuarioActual.EMPLEADO != null?_UsuarioActual.EMPLEADO.PERSONA != null? !string.IsNullOrEmpty(_UsuarioActual.EMPLEADO.PERSONA.MATERNO)?_UsuarioActual.EMPLEADO.PERSONA.MATERNO.Trim() : string.Empty : string.Empty : string.Empty) : string.Empty,
                                   Generico2 = _UsuarioActual != null ? _UsuarioActual.EMPLEADO != null ? !string.IsNullOrEmpty(_UsuarioActual.EMPLEADO.CEDULA) ? _UsuarioActual.EMPLEADO.CEDULA.Trim() : string.Empty : string.Empty : string.Empty
                };

                System.Collections.Generic.List <cMedicamentosRecetaMedica> ListaMedicamentos = new System.Collections.Generic.List <cMedicamentosRecetaMedica>();
                if (LstMedicamentosConAnotaciones != null && LstMedicamentosConAnotaciones.Any())
                {
                    foreach (var item in LstMedicamentosConAnotaciones)
                    {
                        ListaMedicamentos.Add(new cMedicamentosRecetaMedica
                        {
                            Cantidad      = item.Cantidad,
                            Duracion      = item.Duracion,
                            Noche         = item.Noche,
                            Maniana       = item.Maniana,
                            Observaciones = item.Anotaciones,
                            Presentacion  = string.Format("{0} {1}", item.NombreMedicamento, !string.IsNullOrEmpty(item.OBSERVACIONES) ? string.Format("({0})", item.OBSERVACIONES.Trim()) : string.Empty),
                            UnidadMedida  = item.UnidadMedida,
                            Tarde         = item.Tarde,
                        });
                    }
                }
                ;

                var _CeresoActual = new SSP.Controlador.Catalogo.Justicia.cCentro().GetData(x => x.ID_CENTRO == GlobalVar.gCentro).FirstOrDefault();
                var Encabezado    = new cEncabezado()
                {
                    TituloUno       = _CeresoActual != null ? !string.IsNullOrEmpty(_CeresoActual.DESCR) ? _CeresoActual.DESCR.Trim() : string.Empty : string.Empty,
                    TituloDos       = Parametro.ENCABEZADO2,
                    ImagenIzquierda = Parametro.REPORTE_LOGO2,
                    ImagenFondo     = Parametro.REPORTE_LOGO_MEDICINA
                };

                View.Report.LocalReport.ReportPath = "Reportes/rRecetaMedica.rdlc";
                View.Report.LocalReport.DataSources.Clear();


                var ds1 = new System.Collections.Generic.List <cEncabezado>();
                ds1.Add(Encabezado);
                Microsoft.Reporting.WinForms.ReportDataSource rds1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                rds1.Name  = "DataSet1";
                rds1.Value = ds1;
                View.Report.LocalReport.DataSources.Add(rds1);

                var ds2 = new System.Collections.Generic.List <cRecetaMedicaReporte>();
                ds2.Add(DatosReporte);
                Microsoft.Reporting.WinForms.ReportDataSource rds2 = new Microsoft.Reporting.WinForms.ReportDataSource();
                rds2.Name  = "DataSet2";
                rds2.Value = ds2;
                View.Report.LocalReport.DataSources.Add(rds2);

                Microsoft.Reporting.WinForms.ReportDataSource rds3 = new Microsoft.Reporting.WinForms.ReportDataSource();
                rds3.Name  = "DataSet3";
                rds3.Value = ListaMedicamentos;
                View.Report.LocalReport.DataSources.Add(rds3);
                View.Report.RefreshReport();
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }