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);
            }
        }
Beispiel #2
0
        public static TurnInBusinessDTO GetPossibleBusinessWithHour(int serviceId, string latitude, string longitude, bool isDriving, int custId)
        {
            bool pushFlag             = false;
            TurnInBusinessDTO service = new TurnInBusinessDTO();

            service = converters.TurnInBusinessConverters.GetTurnInBusinessDTO(ServiceDal.GetServiceById(serviceId));
            if (latitude != "0" && longitude != "0")
            {
                service.Duration = TurnServices.GooglePlaces(longitude, latitude, service.Address, isDriving);
            }
            else
            {
                service.Duration = 0;
            }
            service.EstimatedHour = ImmediateTurn.GetOptionalHourPerBusiness(serviceId, TimeSpan.FromMinutes(service.Duration).Add(DateTime.Now.TimeOfDay), ref pushFlag);

            try
            {
                if (service.EstimatedHour != new TimeSpan())
                {
                    service.TurnId = ImmediateTurn.MakeTemporaryTurn(service, pushFlag, custId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(service);
        }
        public bool LiberarPaciente(int Category, string ServiceId, string CategoryName, string CalendarId)
        {
            var           serviceComponent    = new ServiceDal().GetServiceComponentByCategoryId(Category, ServiceId);
            int           statusAntiguo       = serviceComponent[0].i_ServiceComponentStatusId.Value;
            List <string> _ServiceComponentId = new List <string>();

            foreach (var item in serviceComponent)
            {
                _ServiceComponentId.Add(item.v_ServiceComponentId);
            }

            DatabaseContext ctx = new DatabaseContext();

            //var objCalendar = ctx.Calendar.Where(x => x.v_CalendarId == CalendarId).FirstOrDefault();
            //objCalendar.i_LineStatusId = 2;
            //ctx.SaveChanges();
            if (CategoryName == "LABORATORIO")
            {
                return(new ServiceDal().LiberarPacientelaboratorio(_ServiceComponentId, statusAntiguo));
            }
            else
            {
                return(new ServiceDal().LiberarPaciente(_ServiceComponentId));
            }
        }
        public static List <DateTime> GetOptionalDaysPerService(int serviceId)
        {
            int                 day           = (int)DateTime.Today.DayOfWeek + 1;
            DateTime            date          = DateTime.Now;
            List <activityTime> activityTimes = ActivityTimeDal.GetActivityTimes(serviceId);
            List <DateTime>     optionalDays  = new List <DateTime>();
            var                 service       = ServiceDal.GetServiceById(serviceId);
            int                 limitDays;

            if (service.kindOfPermission == true)
            {
                limitDays = service.limitDays.Value;
            }
            else
            {
                throw new Exception("בעסק זה לא ניתן לקבוע תורים מראש");
            }
            for (int i = 0; i < limitDays; i++, day++)
            {
                if (day == 7)
                {
                    day = 1;
                    i++;
                    limitDays++;
                }
                if (activityTimes.FirstOrDefault(a => a.dayInWeek == day) != null)
                {
                    optionalDays.Add(date.AddDays(i));
                }
            }
            return(optionalDays);
        }
        public List <Categoria> GetAdditionalExams(BoardExamsCustom data)
        {
            var listAllServicecomponents = new ServiceDal().GetAllComponents(data.TipoBusqueda, data.Value);
            var ListaFinal = new List <Categoria>();

            return(listAllServicecomponents);
        }
Beispiel #6
0
        public bool CircuitStart(string pstrCalendarId, int userId)
        {
            try
            {
                using (var ts = new TransactionScope())
                {
                    var objCalendarDto = ctx.Calendar.Where(x => x.v_CalendarId == pstrCalendarId).FirstOrDefault();
                    var serviceId      = objCalendarDto.v_ServiceId;
                    objCalendarDto.v_CalendarId       = pstrCalendarId;
                    objCalendarDto.i_LineStatusId     = (int)LineStatus.EnCircuito;
                    objCalendarDto.i_CalendarStatusId = (int)CalendarStatus.Atendido;
                    objCalendarDto.d_CircuitStartDate = DateTime.Now;
                    objCalendarDto.d_UpdateDate       = DateTime.Now;
                    objCalendarDto.i_UpdateUserId     = userId;

                    ctx.SaveChanges();

                    var result = new ServiceDal().UpdateServiceForCalendar(DateTime.Now, userId, serviceId);
                    if (!result)
                    {
                        throw new Exception("");
                    }
                    ts.Complete();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public List <Categoria> GetAdditionalExamByServiceId(string serviceId)
        {
            List <string> ComponentAdditionalList = new List <string>();
            List <string> ComponentNewService     = new List <string>();
            var           ListAdditionalExams     = new AdditionalExamDal().GetAdditionalExamByServiceId(serviceId);

            foreach (var obj in ListAdditionalExams)
            {
                ComponentAdditionalList.Add(obj.ComponentId);
                if (obj.IsNewService == (int)SiNo.Si)
                {
                    ComponentNewService.Add(obj.ComponentId);
                }
            }

            List <Categoria> DataSource = new List <Categoria>();

            foreach (var componentId in ComponentAdditionalList)
            {
                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);
                }
            }
            foreach (var item in ListAdditionalExams)
            {
                foreach (var data in DataSource)
                {
                    foreach (var comp in data.Componentes)
                    {
                        if (comp.v_ComponentId == item.ComponentId)
                        {
                            if (item.IsNewService == 1)
                            {
                                comp.i_NewService = 1;
                            }
                            else
                            {
                                comp.i_NewService = 0;
                            }
                        }
                    }
                }
            }
            return(DataSource);
        }
Beispiel #8
0
        public string Schedule(CalendarDto oCalendarDto, int nodeId, int systemUserId)
        {
            //using (var ts = new TransactionScope())
            //{
            var oServiceDto = PopulateServiceDto(oCalendarDto);

            var serviceId = new ServiceDal().AddService(oServiceDto, nodeId, systemUserId);

            AddServiceComponentInBlock(serviceId, oCalendarDto.v_ProtocolId, oCalendarDto.v_PersonId, nodeId,
                                       systemUserId);

            oCalendarDto.v_ServiceId = serviceId;
            AddCalendar(oCalendarDto, nodeId, systemUserId);

            return(serviceId);

            //}
        }
Beispiel #9
0
 public bool AddAdditionalExam(List <AdditionalExamCustom> listAdditionalExam, int userId, int nodeId)
 {
     try
     {
         using (var ts = new TransactionScope())
         {
             bool Result = new ServiceDal().AddAdditionalExam(listAdditionalExam, userId, nodeId);
             if (!Result)
             {
                 throw new Exception("Error");
             }
             ts.Complete();
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #10
0
        /// <summary>
        /// הפונקציה יוצרת רשימת עסקים עם שעות אפשריות ומרחק של כל עסק מהמשתמש
        /// הפונקציה מסננת את הרשימה
        /// </summary>
        /// <param name="categoryId">קטגוריה</param>
        /// <param name="latitude">קו אורך</param>
        /// <param name="longitude">קו רוחב</param>
        /// <param name="isDriving">האם מגיע ברכב או ברגל</param>
        /// <returns>רשימת עסקים מסוננת עם שעה אפשרית</returns>
        public static List <TurnInBusinessDTO> GetPossibleBusinessesWithHour(int categoryId, string latitude, string longitude, bool isDriving, int custId)
        {
            List <TurnInBusinessDTO> services         = new List <TurnInBusinessDTO>();
            List <TurnInBusinessDTO> servicesToReturn = new List <TurnInBusinessDTO>();
            bool pushFlag = false;

            services = converters.TurnInBusinessConverters.GetTurnsInBusinessDTO(ServiceDal.GetServicesByCategory(categoryId));
            if (latitude != "0" && longitude != "0")
            {
                services.ForEach(s => s.Duration = TurnServices.GooglePlaces(longitude, latitude, s.Address, isDriving));
            }
            else
            {
                services.ForEach(s => s.Duration = 0);
            }
            if (services.Count() > 20)
            {
                services.OrderBy(s => s.Duration).Take(20);
            }
            TimeSpan timeToLookFor;

            services.ForEach(s => s.EstimatedHour = ImmediateTurn.GetOptionalHourPerBusiness(s.ServiceId, timeToLookFor = TimeSpan.FromMinutes(s.Duration).Add(DateTime.Now.TimeOfDay), ref pushFlag));
            services.OrderBy(s => s.EstimatedHour);

            services.RemoveAll(s => s.EstimatedHour == new TimeSpan());
            servicesToReturn.AddRange(services.Take(2));
            services.RemoveAll(s => servicesToReturn.Contains(s));
            servicesToReturn.AddRange(services.Where(s => s.Duration == services.Min(d => d.Duration)));
            //  servicesToReturn.Add(services.FirstOrDefault(s => s.Duration == services.Min(d => d.Duration)));
            if (servicesToReturn.Count == 0)
            {
                return(servicesToReturn);
            }
            servicesToReturn.ForEach(s => s.TurnId = ImmediateTurn.MakeTemporaryTurn(s, pushFlag, custId));


            //todoever: להחזיר אוביקטים  לפי הסטוריה מועדפים וכו
            return(servicesToReturn);
        }
        public static MessageCustom CopyPdf()
        {
            MessageCustom msg = new MessageCustom();

            try
            {
                List <string> ListServicesId = ServiceDal.GetServicesId();

                //string sourceFolder = @"E:\Archivos Ocupacional\Reportes Medicos";
                string        sourceFolder      = System.Configuration.ConfigurationManager.AppSettings["rutaReportesIca"];
                string        destinationFolder = string.Format("{0}{1}\\", System.Web.Hosting.HostingEnvironment.MapPath("~/"), System.Configuration.ConfigurationManager.AppSettings["directorioESO"]);
                DirectoryInfo source            = new DirectoryInfo(sourceFolder);
                DirectoryInfo desti             = new DirectoryInfo(destinationFolder);
                // el método GetFiles obtiene todos los archivos de un folder especifico,
                // incluso puedes poner un filtro a que archivos te traiga, como por ejemplo
                // todos los archivos *.png o *.txt

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

                foreach (var sercviceId in ListServicesId)
                {
                    string     busqueda       = string.Format("{0}?.pdf", sercviceId);
                    FileInfo[] filesToExclude = desti.GetFiles(busqueda);

                    if (filesToExclude.Length == 0)
                    {
                        FinalListServicesId.Add(sercviceId);
                    }
                }

                var iterador = 0;

                foreach (var sercviceId in FinalListServicesId)
                {
                    string     busqueda    = string.Format("{0}?.pdf", sercviceId);
                    FileInfo[] filesToCopy = source.GetFiles(busqueda);
                    foreach (FileInfo file in filesToCopy)
                    {
                        if (file.Name == sercviceId || file.Name == sercviceId + ".pdf")
                        {
                            iterador++;
                            file.CopyTo(destinationFolder + "\\" + file.Name);
                        }
                    }
                }

                msg.Error   = false;
                msg.Status  = (int)HttpStatusCode.OK;
                msg.Message = String.Format("Los archivos se movieron de {0} a {1}, con un total de {2} registros.", sourceFolder, destinationFolder, iterador);

                return(msg);
            }
            catch (Exception ex)
            {
                msg.Error   = true;
                msg.Status  = (int)HttpStatusCode.Conflict;
                msg.Message = "Sucedió un error al mover los archivos";

                return(msg);
            }
        }
Beispiel #12
0
        public string CreateService(ServiceCustom data, int nodeId, int userId)
        {
            string serviceId = "";
            List <ProtocolComponentCustom> ListProtocolComponent = new ProtocolComponentDal().GetProtocolComponents(data.ProtocolId);

            if (data.FechaCalendario == null)
            {
                data.ProtocolId = new ProtocolBL().ReturnOrDuplicateProtocol(data, nodeId, userId, ListProtocolComponent);
            }

            serviceId = new ServiceDal().CreateService(data, nodeId, userId);
            if (serviceId == null)
            {
                return(null);
            }



            data.ServiceId = serviceId;

            if (data.MasterServiceTypeId == (int)MasterServiceType.Empresarial)
            {
                bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId);
                if (!result)
                {
                    return(null);
                }
            }
            else
            {
                bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId);
                if (!result)
                {
                    return(null);
                }
            }

            CalendarDto _CalendarDto = new CalendarDto();

            _CalendarDto.v_PersonId          = data.PersonId;
            _CalendarDto.v_ServiceId         = data.ServiceId;
            _CalendarDto.v_PersonId          = data.PersonId;
            _CalendarDto.d_DateTimeCalendar  = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.d_CircuitStartDate  = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.d_EntryTimeCM       = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.i_ServiceTypeId     = data.MasterServiceTypeId;
            _CalendarDto.i_CalendarStatusId  = 1;
            _CalendarDto.i_ServiceId         = data.MasterServiceId;
            _CalendarDto.v_ProtocolId        = data.ProtocolId;
            _CalendarDto.i_NewContinuationId = 1;
            _CalendarDto.i_LineStatusId      = 1;
            _CalendarDto.i_IsVipId           = 0;

            bool calendarResult = new CalendarDal().AddCalendar(_CalendarDto, nodeId, userId);

            if (!calendarResult)
            {
                return(null);
            }
            int tipoEmpresa = ProtocolDal.ObtenerTipoEmpresaByProtocol(data.ProtocolId);

            if ((data.MasterServiceId == 19 || data.MasterServiceId == 10 || data.MasterServiceId == 15 || data.MasterServiceId == 16 || data.MasterServiceId == 17 || data.MasterServiceId == 18 || data.MasterServiceId == 19) && tipoEmpresa == 4)
            {
                bool resultHospi = new HospitalizacionDal().AddHospitalizacion(data.PersonId, data.ServiceId, nodeId, userId);
                if (!resultHospi)
                {
                    return(null);
                }
            }

            return(serviceId);
        }
        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);
            }
        }
        public BoardExamsCustom CallingPacient(BoardExamsCustom data)
        {
            MessageCustom _Message = new MessageCustom();

            List <Dropdownlist> ListaCetegorias = new SystemParameterBL().GetParametroByGrupoId(116);
            var ListaExamenesPrevios            = new SystemParameterBL().GetParametroByGrupoId(306).Find(p => p.Value2 == data.CategoryId);

            if (ListaExamenesPrevios != null)
            {
                var consultorioPrevio = int.Parse(ListaExamenesPrevios.Field);

                if (consultorioPrevio == -1)
                {
                    var examenesNoCulminados = new ServiceBl().GetServiceComponentsCulminados(data.ServiceId);
                    if (examenesNoCulminados == null)
                    {
                        _Message.Error   = true;
                        _Message.Status  = 400;
                        _Message.Message = "Sucedio un error generando las consultas, por favor refresque y vuelva a intentar.";
                        data.Message     = _Message;
                        return(data);
                    }
                    var exam = examenesNoCulminados.FindAll(p => p.i_CategoryId != data.CategoryId);

                    if (exam.Count != 0)
                    {
                        _Message.Error   = true;
                        _Message.Status  = 200;
                        _Message.Message = "Este paciente debe primero CULIMINAR TODOS los examenes anteriores.";
                        data.Message     = _Message;
                        return(data);
                    }
                }

                var listaExamenesProtocolo = new ServiceBl().GetServiceComponents(data.ServiceId).Find(p => p.i_CategoryId == consultorioPrevio);
                if (listaExamenesProtocolo == null)
                {
                    _Message.Error   = true;
                    _Message.Status  = 400;
                    _Message.Message = "Sucedio un error generando las consultas, por favor refresque y vuelva a intentar.";
                    data.Message     = _Message;
                    return(data);
                }
                if (listaExamenesProtocolo != null)
                {
                    var examenesNoCulminados = new ServiceBl().GetServiceComponentsCulminados(data.ServiceId);
                    if (examenesNoCulminados == null)
                    {
                        _Message.Error   = true;
                        _Message.Status  = 400;
                        _Message.Message = "Sucedio un error generando las consultas, por favor refresque y vuelva a intentar.";
                        data.Message     = _Message;
                        return(data);
                    }
                    var result = examenesNoCulminados.Find(p => p.i_CategoryId == consultorioPrevio);

                    if (result != null)
                    {
                        _Message.Error  = true;
                        _Message.Status = 200;
                        int field = int.Parse(ListaExamenesPrevios.Field);
                        _Message.Message = "Este paciente debe primero CULIMINAR  el examen " + ListaCetegorias.Find(p => p.Id == field).Value;
                        data.Message     = _Message;
                        return(data);
                    }
                }
            }

            if (data.Piso != -1)
            {
                var ResultPiso = new ServiceBl().PermitirLlamar(data.ServiceId, data.Piso);
                if (!ResultPiso)
                {
                    _Message.Error   = true;
                    _Message.Status  = 200;
                    _Message.Message = "El Paciente tiene consultorios por culminar, antes de ser llamado por este. Verifíquelo en unos minutos";
                    data.Message     = _Message;
                    return(data);
                }
            }

            if (data.ServiceStatusId == (int)ServiceStatus.EsperandoAptitud)
            {
                _Message.Error   = true;
                _Message.Status  = 200;
                _Message.Message = "Este paciente ya tiene el servicio en espera de Aptitud, no puede ser llamado.";
                data.Message     = _Message;
                return(data);
            }
            var           oServiceComponentList = new ServiceBl().GetServiceComponentByCategoryId(data.CategoryId, data.ServiceId);
            List <string> _ServiceComponentId   = new List <string>();

            foreach (var item in oServiceComponentList)
            {
                _ServiceComponentId.Add(item.v_ServiceComponentId);
            }
            bool resultOff = new ServiceDal().UpdateServiceComponentOfficeLlamando(_ServiceComponentId, data.Oficina);

            if (!resultOff)
            {
                _Message.Error   = true;
                _Message.Status  = 500;
                _Message.Message = "Sucedio un error actualizando la llamada, vuelva a intentar por favor.";
                data.Message     = _Message;
                return(data);
            }
            _Message.Error  = false;
            _Message.Status = 200;
            data.Message    = _Message;
            return(data);
        }
        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 static MessageCustom SendEmail(EmailModel model)
        {
            MessageCustom msg = new MessageCustom();

            try
            {
                List <string> ListPath               = new List <string>();
                var           MedicalCenter          = new ServiceDal().GetInfoMedicalCenter();
                var           ServiceOrder           = ServiceOrderDal.GetOrganizationByServiceOrderId(model.ServiceOrderId);
                var           ListServiceOrderDetail = ServiceOrderDal.GetServicesOrderDetail(model.ServiceOrderId);
                var           ruta     = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["rutaReporteServiceOrder"]);
                var           pathFile = string.Format("{0}.pdf", Path.Combine(ruta, model.ServiceOrderId + "-" + "Report"));
                if (model.TypeEmail == (int)TypeEmail.Ordenservicio)//OrdenServicio
                {
                    var result = Report_ServiceOrderConsolidate.GenerateOrderService(ListServiceOrderDetail, MedicalCenter, ServiceOrder, pathFile);
                    if (!result)
                    {
                        throw new Exception("Sucedió un error generando el reporte, por favor vuelva a intentar");
                    }

                    ListPath.Add(pathFile);
                }
                else
                {
                    var result = Report_ServiceOrderConsolidate.GenerateCotizacion(ListServiceOrderDetail, MedicalCenter, ServiceOrder, pathFile);
                    if (!result)
                    {
                        throw new Exception("Sucedió un error generando el reporte, por favor vuelva a intentar");
                    }

                    ListPath.Add(pathFile);
                }

                using (MailMessage mm = new MailMessage("*****@*****.**", model.To))
                {
                    mm.Subject = model.Subject;
                    mm.Body    = model.Body;
                    foreach (var path in ListPath)
                    {
                        mm.Attachments.Add(new Attachment(path));
                    }


                    mm.IsBodyHtml = false;
                    using (SmtpClient smtp = new SmtpClient())
                    {
                        smtp.Host      = "smtp.gmail.com";
                        smtp.EnableSsl = true;
                        NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "74390363991646704");
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials           = NetworkCred;
                        smtp.Port = 587;
                        smtp.Send(mm);
                    }
                }

                msg.Error   = false;
                msg.Status  = (int)HttpStatusCode.OK;
                msg.Message = "El mensaje se envió correctamente";
                return(msg);
            }
            catch (Exception ex)
            {
                msg.Error   = false;
                msg.Status  = (int)HttpStatusCode.OK;
                msg.Message = ex.Message;
                return(msg);
            }
        }
        public MessageCustom SaveDeletedAdditionalExam(string additionalExamId, int userId, string comentario, string _serviceId)
        {
            comentario = comentario == null ? "SIN COMENTARIOS" : comentario;
            var           result         = new AdditionalExamDal().DeleteAdditionalExam(additionalExamId, userId);
            MessageCustom _MessageCustom = new MessageCustom();

            if (result)
            {
                comentario = comentario == null ? "SIN COMENTARIOS" : comentario;
                string CMP        = "SIN-PROFESIONAL";
                var    ruta       = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["directorioExamAdicional"]);
                var    rutaWeb    = string.Format("{0}.pdf", Path.Combine(_serviceId + "-" + "ORDEN-EX-MED-ADICI-SIN-PROFESIONAL"));
                string pathFile   = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-SIN-PROFESIONAL"));
                var    datosGrabo = new ServiceBl().DevolverDatosUsuarioFirma(userId);
                if (datosGrabo != null)
                {
                    CMP      = datosGrabo.CMP;
                    pathFile = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + datosGrabo.CMP));
                    rutaWeb  = string.Format("{0}.pdf", Path.Combine(_serviceId + "-" + "ORDEN-EX-MED-ADICI-" + datosGrabo.CMP));
                }



                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);
                    }
                }


                var MedicalCenter = new ServiceBl().GetInfoMedicalCenter();
                var DatosPaciente = new PacientBL().DevolverDatosPaciente(_serviceId);

                new PrintAdditionalExam().GenerateAdditionalexam(pathFile, MedicalCenter, DatosPaciente, datosGrabo, comentario, DataSource, ListadditExam);



                _MessageCustom.Error   = false;
                _MessageCustom.Status  = 200;
                _MessageCustom.Message = "Se eliminó correctamente";
                _MessageCustom.Id      = rutaWeb;
            }
            else
            {
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = 500;
                _MessageCustom.Message = "Sucedió un error, vuelva a intentar";
            }
            return(_MessageCustom);
        }
Beispiel #18
0
 public static OrganizationCustom GetInfoMedicalCenterSede()
 {
     return(ServiceDal.GetInfoMedicalCenterSede());
 }