public IHttpActionResult RegistrarCarta(MultiDataModel data)
        {
            MessageCustom _MessageCustom = new MessageCustom();

            try
            {
                bool result = new ServiceBl().RegistrarCarta(data);

                if (!result)
                {
                    throw new Exception("Sucedió un error al agregar la carta, por favor vuelva a intentar.");
                }
                else
                {
                    _MessageCustom.Error = false;
                }
                _MessageCustom.Status  = (int)StatusHttp.Ok;
                _MessageCustom.Id      = data.String1;
                _MessageCustom.Message = "Se agregó correctamente.";
                return(Ok(_MessageCustom));
            }
            catch (Exception ex)
            {
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = (int)StatusHttp.BadRequest;
                _MessageCustom.Message = ex.Message;
                return(Ok(_MessageCustom));
            }
        }
        public IHttpActionResult CreateCalendar(MultiDataModel data)
        {
            MessageCustom _MessageCustom = new MessageCustom();

            try
            {
                using (var ts = new TransactionScope())
                {
                    var    dataService = JsonConvert.DeserializeObject <ServiceCustom>(data.String1);
                    string serviceId   = new ServiceBl().CreateService(dataService, data.Int1, data.Int2);

                    if (serviceId == null)
                    {
                        throw new Exception("Sucedió un error al generar la agenda, por ello no se guardó ningún cambio.");
                    }
                    else
                    {
                        _MessageCustom.Error = false;
                    }
                    _MessageCustom.Status  = (int)StatusHttp.Ok;
                    _MessageCustom.Id      = serviceId;
                    _MessageCustom.Message = "Se agendó correctamente.";
                    ts.Complete();
                    return(Ok(_MessageCustom));
                }
            }
            catch (Exception ex)
            {
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = (int)StatusHttp.BadRequest;
                _MessageCustom.Message = ex.Message;
                return(Ok(_MessageCustom));
            }
        }
        public IHttpActionResult FusionarServicios(MultiDataModel data)
        {
            List <string> ServicesId = JsonConvert.DeserializeObject <List <string> >(data.String1);
            var           result     = new ServiceBl().FusionarServicios(ServicesId, data.Int1, data.Int2);

            return(Ok(result));
        }
        public bool BuscarCoincidencia(string serviceId, string componentId)
        {
            var listServicecomponents = new ServiceBl().GetServiceComponents(serviceId);

            var find = listServicecomponents.Find(x => x.v_ComponentId == componentId);

            if (find != null)
            {
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        public List <KeyValueDTO> GetAllComponent(int nodeId, int rolenodeId)
        {
            var components = new ComponentDal().GetAllComponents();
            var temp       = components.FindAll(p => p.Value4 != -1);
            List <KeyValueDTO> groupComponentList = temp.GroupBy(x => x.Value4).Select(group => group.First()).ToList();

            groupComponentList.AddRange(components.ToList().FindAll(p => p.Value4 == -1));
            var componentProfile = new ServiceBl().GetRoleNodeComponentProfileByRoleNodeId(nodeId, rolenodeId);
            var results          = groupComponentList.FindAll(f => componentProfile.Any(t => t.v_ComponentId == f.Value2));

            return(results);
        }
        public MessageCustom EliminarExamen(BoardExamsCustom data, int userId)
        {
            MessageCustom _Message        = new MessageCustom();
            var           _auxiliaryExams = new List <ServiceComponentList>();

            if (data.CategoryId == -1)
            {
                ServiceComponentList auxiliaryExam = new ServiceComponentList();
                auxiliaryExam.v_ServiceComponentId = data.ServicecomponentId;
                _auxiliaryExams.Add(auxiliaryExam);
            }
            else
            {
                var oServiceComponentList = new ServiceBl().GetServiceComponentByCategoryId(data.CategoryId, data.ServiceId);
                if (oServiceComponentList == null)
                {
                    _Message.Error   = true;
                    _Message.Status  = (int)StatusHttp.BadRequest;
                    _Message.Message = "Sucedió un error al consultar los componentes del servicio.";
                    return(_Message);
                }
                foreach (var scid in oServiceComponentList)
                {
                    ServiceComponentList auxiliaryExam = new ServiceComponentList();
                    auxiliaryExam.v_ServiceComponentId = scid.v_ServiceComponentId;
                    _auxiliaryExams.Add(auxiliaryExam);
                }
            }
            bool result = new ServiceBl().UpdateAdditionalExam(_auxiliaryExams, data.ServiceId, (int)SiNo.No, userId);

            if (!result)
            {
                _Message.Error   = true;
                _Message.Status  = (int)StatusHttp.BadRequest;
                _Message.Message = "Sucedió un error al actualizar los examenes, no se guardó ningun cambio.";
                return(_Message);
            }

            _Message.Error   = false;
            _Message.Status  = (int)StatusHttp.Ok;
            _Message.Message = "Los cambios se guardaron correctamente.";
            return(_Message);
        }
Beispiel #7
0
        public bool CreateService(ServiceBl service)
        {
            try
            {
                _context.Service.Add(new Service
                {
                    Id          = service.Id,
                    Cost        = service.Cost,
                    Description = service.Description,
                    NameService = service.NameService
                });
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public IHttpActionResult UpdateServiceForProtocol(MultiDataModel data)
        {
            MessageCustom _MessageCustom = new MessageCustom();

            try
            {
                using (var ts = new TransactionScope())
                {
                    var  dataService   = JsonConvert.DeserializeObject <ServiceCustom>(data.String1);
                    bool resultService = new ServiceBl().UpdateServiceForProtocol(dataService, data.Int1);
                    if (!resultService)
                    {
                        throw new Exception("Sucedió un error al actualizar el servicio, por ello no se guardó ningún cambio.");
                    }

                    bool resultCalendar = new CalendarBL().UpdateCalendarForProtocol(dataService, data.Int1);
                    if (!resultCalendar)
                    {
                        throw new Exception("Sucedió un error al actualizar la agenda, por ello no se guardó ningún cambio.");
                    }

                    else
                    {
                        _MessageCustom.Error = false;
                    }
                    _MessageCustom.Status  = (int)StatusHttp.Ok;
                    _MessageCustom.Id      = "";
                    _MessageCustom.Message = "Se actualizó correctamente.";
                    ts.Complete();
                    return(Ok(_MessageCustom));
                }
            }
            catch (Exception ex)
            {
                _MessageCustom.Error   = true;
                _MessageCustom.Status  = (int)StatusHttp.BadRequest;
                _MessageCustom.Message = ex.Message;
                return(Ok(_MessageCustom));
            }
        }
Beispiel #9
0
        public static MessageCustom GenerateServiceOrderReport(BoardServiceOrder data, int userId, string FechaEmision)
        {
            MessageCustom msg = new MessageCustom();

            try
            {
                var MedicalCenter   = ServiceBl.GetInfoMedicalCenterSede();
                var pEmpresaCliente = data.EntityserviceOrder.v_OrganizationName;
                //var _DataService = ProtocolBL.GetProtocolById(ProtocolId);
                List <ProtocolComponentCustom> ListaComponentes = new List <ProtocolComponentCustom>();
                List <ServiceOrderPdf>         Lista            = new List <ServiceOrderPdf>();
                foreach (var objServiceOrder in data.ListEntityServiceOrder)
                {
                    ServiceOrderPdf objSerOrdPdf = new ServiceOrderPdf();

                    var oProtocolo = ProtocolBL.GetProtocolById(objServiceOrder.v_ProtocolId);
                    objSerOrdPdf.v_ServiceOrderId = data.EntityserviceOrder.v_ServiceOrderId;
                    objSerOrdPdf.EmpresaCliente   = oProtocolo.v_OrganizationInvoice + " / " + oProtocolo.v_GroupOccupation + " / " + oProtocolo.v_EsoType;
                    var board = ProtocolBL.GetProtocolComponentByProtocolId(objServiceOrder.v_ProtocolId);
                    ListaComponentes = board.ListProtocolComponents;
                    List <ServiceOrderDetailPdf> ListaServiceOrderDetailPdf = new List <ServiceOrderDetailPdf>();
                    foreach (var Componente in ListaComponentes)
                    {
                        ServiceOrderDetailPdf oServiceOrderDetailPdf = new ServiceOrderDetailPdf();
                        oServiceOrderDetailPdf.v_ServiceOrderDetailId = data.ListEntityServiceOrder.Find(p => p.v_ProtocolId == oProtocolo.v_ProtocolId).v_ServiceOrderDetailId;
                        oServiceOrderDetailPdf.v_ServiceOrderId       = data.EntityserviceOrder.v_ServiceOrderId;
                        oServiceOrderDetailPdf.v_ComponentId          = Componente.ComponentId;
                        oServiceOrderDetailPdf.Componente             = Componente.ComponentName;
                        oServiceOrderDetailPdf.v_Precio = Componente.Price;
                        ListaServiceOrderDetailPdf.Add(oServiceOrderDetailPdf);
                    }
                    objSerOrdPdf.DetalleServiceOrder = ListaServiceOrderDetailPdf;
                    objSerOrdPdf.TotalProtocolo      = ListaServiceOrderDetailPdf.Sum(s => s.v_Precio);
                    Lista.Add(objSerOrdPdf);
                }

                var oSystemUserList = new SecurityDal().GetSystemUserAndProfesional(userId);

                string ruta = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["rutaCotizacion"]);
                string path = ruta + "/" + data.EntityserviceOrder.v_ServiceOrderId + ".pdf";
                if (data.EntityserviceOrder.i_EsProtocoloEspecial == (int)SiNo.Si)
                {
                    OrdenServicioPromocion.CrearOrdenServicio(data.EntityserviceOrder.i_MostrarPrecio == (int)SiNo.Si ? true : false, Lista, MedicalCenter, pEmpresaCliente, DateTime.Parse(FechaEmision).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList == null ? "" : oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, path);
                }
                else
                {
                    OrdenServicio.CrearOrdenServicio(data.EntityserviceOrder.i_MostrarPrecio == (int)SiNo.Si ? true : false, Lista, MedicalCenter, pEmpresaCliente, data.EntityserviceOrder.v_ServiceOrderId, DateTime.Parse(FechaEmision).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList == null ? "" : oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, path);
                }
                msg.Error  = false;
                msg.Id     = data.EntityserviceOrder.v_ServiceOrderId + ".pdf";
                msg.Status = (int)HttpStatusCode.Accepted;
                return(msg);
            }
            catch (Exception ex)
            {
                msg.Error   = true;
                msg.Status  = (int)HttpStatusCode.BadRequest;
                msg.Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(msg);
            }
        }
        public IHttpActionResult GetListSaldosPaciente(string serviceId)
        {
            var result = new ServiceBl().GetListSaldosPaciente(serviceId);

            return(Ok(result));
        }
        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);
        }
        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 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);
            }
        }
Beispiel #14
0
        public IHttpActionResult GetAllComponentsByService(string serviceId)
        {
            var result = ServiceBl.GetAllComponentsByService(serviceId);

            return(Ok(result));
        }