public MessageCustom ReImprimirAdicional(int userId, string serviceId)
        {
            MessageCustom _MessageCustom = new MessageCustom();

            try
            {
                MergeExPDF _mergeExPDF = new MergeExPDF();
                #region BuscarPDF
                var           ruta       = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioExamAdicional"]);
                var           rutaBasura = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioBasura"]);
                var           datosGrabo = new ServiceDal().DevolverDatosUsuarioFirma(userId);
                var           CMP        = datosGrabo == null ? "SIN-PROFESIONAL" : datosGrabo.CMP;
                List <string> pdfList    = new List <string>();
                pdfList.Add(string.Format("{0}.pdf", Path.Combine(ruta, serviceId + "-" + "ORDEN-EX-MED-ADICI-" + CMP)));
                _mergeExPDF.FilesName       = pdfList;
                _mergeExPDF.DestinationFile = string.Format("{0}.pdf", Path.Combine(rutaBasura, "REIMPRESO-" + serviceId + "-" + CMP));
                _mergeExPDF.Execute();

                _MessageCustom.Id     = string.Format("{0}.pdf", Path.Combine("REIMPRESO-" + serviceId + "-" + CMP));
                _MessageCustom.Error  = false;
                _MessageCustom.Status = 200;
                #endregion
                return(_MessageCustom);
            }
            catch (Exception ex)
            {
                _MessageCustom.Message = "No existen PDFs por reimprimir.";
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = 500;
                return(_MessageCustom);
            }
        }
Exemple #2
0
        private void link_Click(object sender, System.EventArgs e)
        {
            string rutaReportes = WebConfigurationManager.AppSettings["rutaReportes"];

            OperationResult objOperationResult = new OperationResult();
            LinkButton      senderCtrl         = (LinkButton)sender;
            string          path;
            List <string>   _filesNameToMerge = new List <string>();
            MergeExPDF      _mergeExPDF       = new MergeExPDF();

            _filesNameToMerge.Add(rutaReportes + Session["ServiceId"].ToString() + "-FMT.pdf");
            //_filesNameToMerge.Add(rutaReportes + Session["ServiceId"].ToString() + "-312.pdf");
            //_filesNameToMerge.Add(rutaReportes + Session["ServiceId"].ToString() + "-7C.pdf");

            var x = _filesNameToMerge.ToList();

            _mergeExPDF.FilesName       = x;
            _mergeExPDF.DestinationFile = rutaReportes + "Descargar Historia" + ".pdf";// Server.MapPath(@"\TempMerge\" + "Descargar" + ".pdf");
            _mergeExPDF.DestinationFile = rutaReportes + "Descargar Historia" + ".pdf";
            _mergeExPDF.Execute();
            path = rutaReportes + "Descargar Historia" + ".pdf";
            Download(senderCtrl.Text, path);
        }
        private void link_Click(object sender, System.EventArgs e)
        {
            string rutaReportes = WebConfigurationManager.AppSettings["rutaReportes"];

            OperationResult  objOperationResult = new OperationResult();
            LinkButton       senderCtrl         = (LinkButton)sender;
            string           path;
            List <MyListWeb> ListaServicios    = (List <MyListWeb>)Session["objLista"];
            List <string>    _filesNameToMerge = new List <string>();
            MergeExPDF       _mergeExPDF       = new MergeExPDF();

            foreach (var item in ListaServicios)
            {
                _filesNameToMerge.Add(rutaReportes + item.IdServicio.ToString() + "-CAPE.pdf");
            }
            var x = _filesNameToMerge.ToList();

            _mergeExPDF.FilesName       = x;
            _mergeExPDF.DestinationFile = rutaReportes + "Descargar Certificado" + ".pdf";// Server.MapPath(@"\TempMerge\" + "Descargar" + ".pdf");
            _mergeExPDF.DestinationFile = rutaReportes + "Descargar Certificado" + ".pdf";
            _mergeExPDF.Execute();
            path = rutaReportes + "Descargar Certificado" + ".pdf";
            Download(senderCtrl.Text, path);
        }
        public MessageCustom GenerateHistoriaClinica(string personId, string serviceId)
        {
            MessageCustom _MessageCustom = new MessageCustom();

            try
            {
                DatabaseContext ctx         = new DatabaseContext();
                var             ruta        = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioHistoriaClinica"]);
                var             rutaBasura  = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioBasura"]);
                string          pathFile    = string.Format("{0}.pdf", Path.Combine(ruta, serviceId + "-" + "HISTORIA-CLINICA"));
                var             objPacient  = ctx.Person.Where(x => x.v_PersonId == personId).FirstOrDefault();
                int             Edad        = new PacientBL().GetEdad(objPacient.d_Birthdate.Value);
                int             GrupoEtario = ObtenerIdGrupoEtarioDePaciente(Edad);


                List <EsoCuidadosPreventivosComentarios> Comentarios = new EsoAntecedentesDal().ObtenerComentariosCuidadosPreventivos(personId);
                var listaProblema    = new PlanIntegralDal().GetProblemaPagedAndFiltered(personId);
                var listPlanIntegral = new PlanIntegralDal().GetPlanIntegral(personId);
                var datosPersonales  = new PacientBL().GetDatosPersonalesAtencion(serviceId);
                var datosP           = new PacientBL().DevolverDatosPaciente(serviceId);
                int GrupoBase        = ObtenerGrupoBase(GrupoEtario, objPacient);
                int Grupo            = int.Parse(GrupoBase.ToString() + GrupoEtario.ToString());
                if (Edad <= 12)
                {
                    GrupoEtario = 4;
                    Grupo       = 2824;
                }
                else if (13 <= Edad && Edad <= 17)
                {
                    GrupoEtario = 2;
                    Grupo       = 2822;
                }
                else if (18 <= Edad && Edad <= 64)
                {
                    GrupoEtario = 1;
                    Grupo       = 2821;
                }
                else
                {
                    GrupoEtario = 3;
                    Grupo       = 2823;
                }
                var listAntecedentes = new EsoAntecedentesDal().ObtenerEsoAntecedentesPorGrupoId(Grupo, GrupoEtario, personId);
                var datosNin         = new EsoAntecedentesDal().DevolverNinio(serviceId);
                var datosAdol        = new EsoAntecedentesDal().DevolverAdolescente(serviceId);
                var datosAdul        = new EsoAntecedentesDal().DevolverAdulto(serviceId);
                var datosAdulMay     = new EsoAntecedentesDal().DevolverAdultoMayor(serviceId);
                List <EsoCuidadosPreventivosFechas> Fechas = new EsoAntecedentesBL().ObtenerFechasCuidadosPreventivos(personId);

                foreach (var F in Fechas)
                {
                    F.Listado = new EsoAntecedentesDal().ObtenerListadoCuidadosPreventivos(GrupoBase, personId, F.FechaServicio);
                }
                if (Fechas.Count > 6)
                {
                    Fechas = Fechas.Skip((Fechas.Count - 6)).ToList();
                }
                var MedicalCenter = new ServiceDal().GetInfoMedicalCenter();

                var listEmb = new EsoAntecedentesDal().GetEmbarazos(personId);

                //primer pdf
                var pathFile2            = string.Format("{0}.pdf", Path.Combine(ruta, serviceId + "-" + "HISTORIA-CLINICA-INTEGRAL"));
                var exams                = new SigesoftDal().GetServiceComponentsReport(serviceId);
                var medico               = new PacientBL().ObtenerDatosMedicoMedicina(serviceId, Constants.ATENCION_INTEGRAL_ID, Constants.EXAMEN_FISICO_7C_ID);
                var datosGrabo           = new ServiceDal().DevolverDatosUsuarioGraboExamen((int)CategoryTypeExam.ExamenFisico, serviceId);
                var diagnosticRepository = new ServiceDal().GetServiceComponentConclusionesDxServiceIdReport(serviceId);
                var medicina             = new ServiceDal().GetReceta(serviceId);
                var medicoTratante       = new ServiceDal().GetMedicoTratante(serviceId);
                AtencionIntegral.CreateAtencionIntegral(pathFile2, medico, datosP, listAntecedentes, MedicalCenter, exams, datosNin, datosAdol, datosAdul, listEmb, datosAdulMay, diagnosticRepository, medicina, exams, medicoTratante, datosGrabo);
                //////////////////

                if (GrupoEtario == (int)Enumeratores.GrupoEtario.Ninio)
                {
                    Ninio.CreateAtencionNinio(pathFile, listaProblema, listPlanIntegral, datosPersonales, datosP, listAntecedentes, Fechas, MedicalCenter, datosNin, Comentarios);
                }
                else if (GrupoEtario == (int)Enumeratores.GrupoEtario.Adolecente)
                {
                    GrupoBase = 285;
                    if (datosPersonales.Genero.ToUpper() == "MUJER")
                    {
                        GrupoBase = 283;
                    }
                    var Fechas2 = new EsoAntecedentesDal().ObtenerFechasCuidadosPreventivos(personId);
                    foreach (var F in Fechas2)
                    {
                        F.Listado = new EsoAntecedentesDal().ObtenerListadoCuidadosPreventivos(GrupoBase, personId, F.FechaServicio);
                        foreach (var obj in F.Listado)
                        {
                            var find = Comentarios.Find(x => x.GrupoId == obj.GrupoId && x.ParametroId == obj.ParameterId);
                            if (find != null)
                            {
                                obj.DataComentario = find;
                            }
                        }
                    }
                    listAntecedentes = new EsoAntecedentesDal().ObtenerEsoAntecedentesPorGrupoId(2822, GrupoEtario, personId);
                    AtencionIntegralAdolescente.CreateAtencionIntegral(pathFile, listaProblema, listPlanIntegral, datosPersonales, datosP, listAntecedentes, Fechas2, MedicalCenter, datosAdol, Comentarios);
                }
                else if (GrupoEtario == (int)Enumeratores.GrupoEtario.Adulto)
                {
                    listAntecedentes = new EsoAntecedentesDal().ObtenerEsoAntecedentesPorGrupoId(2821, GrupoEtario, personId);
                    AtencionIntegralAdulto.CreateAtencionIntegral(pathFile, listaProblema, listPlanIntegral, datosPersonales, datosP, listAntecedentes, Fechas, MedicalCenter, datosAdul, listEmb, Comentarios);
                }
                else if (GrupoEtario == (int)Enumeratores.GrupoEtario.AdultoMayor)
                {
                    listAntecedentes = new EsoAntecedentesDal().ObtenerEsoAntecedentesPorGrupoId(2823, GrupoEtario, personId);
                    AtencionIntegralAdultoMayor.CreateAtencionIntegral(pathFile, listaProblema, listPlanIntegral, datosPersonales, datosP, listAntecedentes, Fechas, MedicalCenter, datosAdulMay, listEmb, Comentarios);
                }

                List <string> pdfList = new List <string>();

                pdfList.Add(pathFile2);
                pdfList.Add(pathFile);
                MergeExPDF _mergeExPDF = new MergeExPDF();
                _mergeExPDF.FilesName       = pdfList;
                _mergeExPDF.DestinationFile = string.Format("{0}.pdf", Path.Combine(rutaBasura, serviceId + "-COPIA-HISTORIA-CLINICA"));
                _mergeExPDF.Execute();

                _MessageCustom.Id     = string.Format("{0}.pdf", Path.Combine(serviceId + "-COPIA-HISTORIA-CLINICA"));
                _MessageCustom.Error  = false;
                _MessageCustom.Status = (int)StatusHttp.Ok;
                return(_MessageCustom);
            }
            catch (Exception ex)
            {
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = (int)StatusHttp.BadRequest;
                _MessageCustom.Message = "Sucedió un error, por favor vuelva a intentar.";
                return(_MessageCustom);
            }
        }
        public MessageCustom SaveadditionalExams(List <AdditionalExamCustom> listExams, int userId, int nodeId)
        {
            try
            {
                MessageCustom _MessageCustom = new MessageCustom();
                var           resul          = new ServiceBl().AddAdditionalExam(listExams, userId, nodeId);

                if (resul)
                {
                    _MessageCustom.Error   = false;
                    _MessageCustom.Status  = (int)StatusHttp.Ok;
                    _MessageCustom.Message = "Los exámenes se agregaron correctamente";
                }
                else
                {
                    _MessageCustom.Error   = true;
                    _MessageCustom.Status  = (int)StatusHttp.BadRequest;
                    _MessageCustom.Message = "Sucedió un error y no se agregaron los exámenes adicionales";
                }

                #region Para imprimir los exámenes
                var _serviceId    = listExams[0].ServiceId;
                var datosGrabo    = new ServiceBl().DevolverDatosUsuarioFirma(userId);
                var MedicalCenter = new ServiceBl().GetInfoMedicalCenter();
                var DatosPaciente = new PacientBL().DevolverDatosPaciente(_serviceId);
                List <Categoria> AdditionalExam = new List <Categoria>();
                List <Categoria> DataSource     = new List <Categoria>();
                List <string>    ComponentList  = new List <string>();
                var ListadditExam = new ServiceDal().GetAdditionalExamByServiceId_all(_serviceId, userId);

                foreach (var componenyId in ListadditExam)
                {
                    ComponentList.Add(componenyId.ComponentId);
                }

                foreach (var componentId in ComponentList)
                {
                    var ListServiceComponent = new ServiceDal().GetAllComponents((int)TipoBusqueda.ComponentId, componentId);

                    Categoria categoria = DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId);
                    if (categoria != null)
                    {
                        List <ComponentDetailList> componentDetail = new List <ComponentDetailList>();
                        componentDetail = ListServiceComponent[0].Componentes;
                        DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId).Componentes.AddRange(componentDetail);
                    }
                    else
                    {
                        DataSource.AddRange(ListServiceComponent);
                    }
                }


                string CMP        = "SIN-PROFESIONAL";
                var    ruta       = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioExamAdicional"]);
                var    rutaBasura = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioBasura"]);
                string pathFile   = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-SIN-PROFESIONAL"));
                if (datosGrabo != null)
                {
                    if (datosGrabo.CMP != null)
                    {
                        CMP      = datosGrabo.CMP;
                        pathFile = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + datosGrabo.CMP));
                    }
                }
                new PrintAdditionalExam().GenerateAdditionalexam(pathFile, MedicalCenter, DatosPaciente, datosGrabo, listExams[0].Commentary, DataSource, ListadditExam);
                List <string> pdfList = new List <string>();
                pdfList.Add(pathFile);
                MergeExPDF _mergeExPDF = new MergeExPDF();
                _mergeExPDF.FilesName       = pdfList;
                _mergeExPDF.DestinationFile = string.Format("{0}.pdf", Path.Combine(rutaBasura, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + CMP));
                _mergeExPDF.Execute();
                #endregion
                _MessageCustom.Id = string.Format("{0}.pdf", Path.Combine(_serviceId + "-" + "ORDEN-EX-MED-ADICI-" + CMP));
                return(_MessageCustom);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }