public Afiliado GetElegibilidad([FromBody] Elegibilidad id) { var afiliado = new Afiliado(); try { if (ModelState.IsValid) { OsStatus.Medife = DateTime.Now; id.UserId = User.Identity.Name; var os = new OSRepository(); return(os.Elegibilidad(id)); } afiliado.ModelError = true; var error = ModelState.Values.FirstOrDefault() != null?ModelState.Values.FirstOrDefault().Errors[0].ErrorMessage : string.Empty; afiliado.SetError(GetType().Name, 0, error, string.Empty, id, string.Empty); } catch (Exception ex) { afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, id, string.Empty); } return(afiliado); }
public Afiliado Elegibilidad(Elegibilidad model) { try { var prestador = new PrestadorRepository(); var matricula = 0; switch (model.OsId) { case 0: break; case 1: //Swiss Medical var swiss = new OSSwiss(); return(swiss.Eligibilidad(model.Credencial)); case 2: var acaSalud = new OSAcaSalud(); matricula = prestador.GetMatriculaFromIdPre(model.IdPre); return(acaSalud.Elegibilidad(model.Credencial, matricula)); case 3: break; case 4: break; case 5: case 8: var boreal = new OSBoreal(); return(boreal.Eligibilidad(model.Credencial)); case 6: var medife = new OSMedife(); return(medife.Eligibilidad(model.Credencial)); case 7: var redSeguros = new OSRedSeguros(); return(redSeguros.Eligibilidad(model.Credencial)); case 9: var sancor = new OSSancor(); matricula = prestador.GetMatriculaFromIdPre(model.IdPre); return(sancor.Elegibilidad(model.Credencial)); case 10: var lyf = new OSLuzFuerza(); var datos = prestador.GetInfoFromIdPre(model.IdPre); Afiliado afiliado = lyf.Eligibilidad(model.Credencial, Convert.ToInt32(datos.Matricula)).Result; if (!afiliado.HasError) { Authorize autoriza = new Authorize(model.OsId, model.IdPre, model.IdPre, model.Credencial, string.Empty, new List <Prestacion>(), model.UserId); autoriza.AfiliadoNombre = afiliado.Name; autoriza.AfiliadoPlan = ""; autoriza.Efector = new Efector(); autoriza.Efector.Matricula = matricula; autoriza.Efector.Name = datos.Name; autoriza.Prestaciones = new List <Prestacion>(); var presta = new Prestacion(); presta.Cant = 1; presta.CodPres = "420101"; presta.Descripcion = "CONSULTA MEDICA"; autoriza.Prestaciones.Add(presta); var autorizacionOs = lyf.Autorizar(autoriza, afiliado.Plan); if (!autorizacionOs.HasError) { var autorizacionRepository = new AutorizacionRepository(); var authNr = autorizacionRepository.Autorizar(autorizacionOs); afiliado.Nr = authNr.ToString(); } } else { if (afiliado.Name == "afiliado inexistente") { afiliado.HasError = false; } else { if (afiliado.Name == "afiliado con 2 consultas realizadas en el mes") { afiliado.Name = "El afiliado supero el límite de consumo mensual. Por favor digerirse a las oficinas de la Obra Social para la autorización de la práctica. "; } else { if (afiliado.Name != "Error el formato del carnet es incorrecto! Ej. xx-xxxxx-x/xx") { afiliado.SetError(GetType().Name, 0, "Luz y Fuerza: " + afiliado.Name, string.Empty, model.Credencial + ";" + datos.Matricula, string.Empty); afiliado.Name = "Se ha producido un error desconocido. Por favor comunicarse con el Área de Sistemas del Circulo Medico de Salta"; } } } } afiliado.Plan = ""; return(afiliado); //case 11: // var os = new OSOspatrones(); // matricula = prestador.GetMatriculaFromIdPre(model.IdPre); // return os.Eligibilidad(model.Credencial, matricula); } } catch (Exception ex) { var errors = new Errores(); errors.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty); } return(new Afiliado()); }