Esempio n. 1
0
        public Afiliado Eligibilidad(string credencial)
        {
            var afiliado = new Afiliado();

            try
            {
                var output = "MSH|^~\\&|TRIA0100M|TRIA00007160|MEDIFE|MEDIFE^222222^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQI^Z01^ZQI_Z01|05091908480623465897|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||30543364610^CU|";

                output += Environment.NewLine;
                output += "PID|||" + credencial + "^^^MEDIFE^HC^MEDIFE||UNKNOWN";
                output += Environment.NewLine;

                var resultado = _traditum.Send(output);
                logResult(output.ToString(), resultado.ToString(), "E");

                if (resultado == "")
                {
                    return new Afiliado {
                               Name = Mensajes.Get("AfiIne")
                    }
                }
                ;

                if (resultado.Contains("Error ejecutando") || resultado.Contains("no se pueden procesar") || resultado.Contains("Unable to read data"))
                {
                    return(new Afiliado {
                        Name = Mensajes.Get("ServidorNoResponde"), HasError = true
                    });
                }

                // convertimos respuesta en vector
                var msHL7 = HL7.DecifraHL7(resultado);
                var index = msHL7[1].IndexOf("En estos momentos, no se pueden procesar transacciones");
                if (index > 0)
                {
                    afiliado.Name = Mensajes.Get("ServidorNoResponde");
                    afiliado.SetError(GetType().Name, 37, Mensajes.Get("ServidorNoResponde"), string.Empty, credencial, string.Empty);
                }
                else
                {
                    if (HL7.CampoHL7(msHL7[2], 3, 1) == "B000")
                    {
                        afiliado.Name = HL7.CampoHL7(msHL7[4], 5, 1) + ", " + HL7.CampoHL7(msHL7[4], 5, 2);
                        afiliado.Plan = HL7.CampoHL7(msHL7[5], 2, 0);
                    }
                    else
                    {
                        afiliado.Name = Mensajes.Get("AfiIne");
                    }
                }
            }
            catch (Exception ex)
            {
                afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", credencial, string.Empty);
            }
            return(afiliado);
        }
Esempio n. 2
0
        public async Task <Afiliado> Eligibilidad(string credencial, int matricula)
        {
            var afiliado = new Afiliado();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://api.osgestion.com.ar/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var cred = credencial.Replace("-", "").Replace("/", "");
                    if (cred.Length == 10)
                    {
                        // var url = "api/crear-consulta/100998/" + cred + "/" + matricula;
                        var url = "api/crear-consulta/" + cred + "/" + matricula;

                        Task <HttpResponseMessage> response = client.GetAsync(url);
                        var resultado = await response.Result.Content.ReadAsStringAsync();

                        logResult(url.ToString(), resultado.ToString(), "E");

                        var luz = (LuzFuerzaResponse)JsonConvert.DeserializeObject(resultado, typeof(LuzFuerzaResponse));


                        if (luz.success.ToUpper() == "TRUE")
                        {
                            afiliado.Name     = luz.name;
                            afiliado.HasError = false;
                        }
                        else
                        {
                            afiliado.Name     = luz.error;
                            afiliado.HasError = true;
                        }
                        afiliado.Plan = luz.authcod;
                    }
                    else
                    {
                        afiliado.Name     = "Error el formato del carnet es incorrecto! Ej. xx-xxxxx-x/xx";
                        afiliado.HasError = true;
                    }
                }
            }
            catch (Exception ex)
            {
                afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", credencial + ";" + matricula, string.Empty);
                afiliado.Error.Mensaje = Mensajes.Get("ServidorNoResponde");
                afiliado.Name          = Mensajes.Get("ServidorNoResponde");
            }
            return(afiliado);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public Afiliado Eligibilidad(string credencial)
        {
            const string url = "http://ws1.rsmprestadores.com/datos_afil.php?cuit=30-54336461-0&clave=4610&afil=";

            try
            {
                var request    = WebRequest.Create(url + credencial);         // Create a request for the URL.
                var response   = request.GetResponse();                       // Get the response.
                var dataStream = response.GetResponseStream();                // Get the stream containing content returned by the server.
                var reader     = new StreamReader(dataStream);                // Open the stream using a StreamReader for easy access.
                var resultado  = reader.ReadToEnd();                          // Read the content.
                reader.Close();                                               // Display the content.
                response.Close();

                var resul = resultado.Split(':');
                var datos = resul[1].Split(',');

                logResult(request.ToString(), resultado.ToString(), "E");

                if (resul[0].Trim() == "OK")
                {
                    return(new Afiliado
                    {
                        Name = datos[1],
                        Plan = datos[4]
                    });
                }
                return(new Afiliado {
                    Error = new Error {
                        Mensaje = "Credencial con formato incorrecto"
                    }, HasError = true, Name = "Credencial con formato incorrecto"
                });
            }
            catch (Exception ex)
            {
                var afi = new Afiliado();
                afi.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, credencial, string.Empty);
                return(afi);
            }
        }
Esempio n. 5
0
        public Afiliado Eligibilidad(string credencial, int matricula)
        {
            var afiliado = new Afiliado();

            try
            {
                string resultado;

                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("Mensaje");

                    writer.WriteStartElement("EncabezadoMensaje");
                    writer.WriteElementString("VersionMsj", "ACT20");
                    writer.WriteElementString("TipoMsj", "OL");
                    writer.WriteElementString("TipoTransaccion", "01A");
                    writer.WriteStartElement("InicioTrx");
                    writer.WriteElementString("FechaTrx", DateTime.Now.ToString("yyyyMMdd"));
                    writer.WriteEndElement();
                    writer.WriteStartElement("Terminal");
                    writer.WriteElementString("TipoTerminal", "PC");
                    writer.WriteElementString("NumeroTerminal", "60000001");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Financiador");
                    writer.WriteElementString("CodigoFinanciador", "PATCAB");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Prestador");
                    writer.WriteElementString("CuitPrestador", "30543364610");
                    writer.WriteElementString("RazonSocial", "Circulo Medico de Salta");
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteStartElement("EncabezadoAtencion");
                    writer.WriteStartElement("Credencial");
                    writer.WriteElementString("NumeroCredencial", credencial); //"0100002201"
                    writer.WriteElementString("ModoIngreso", "M");
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                try
                {
                    resultado = service.ExecuteFileTransactionSLAsync("0000", output.ToString()).Result;
                    logResult(output.ToString(), resultado.ToString(), "E");
                }
                catch (Exception ex)
                {
                    afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", credencial + ";" + matricula, string.Empty);
                    afiliado.Error.Mensaje = Mensajes.Get("ServidorNoResponde");
                    afiliado.Name          = Mensajes.Get("ServidorNoResponde");

                    resultado = "";
                }

                if (resultado == "")
                {
                    afiliado.Name = Mensajes.Get("AfiIne");
                }
                else
                {
                    var nombre = "";
                    var plan   = "";
                    using (var reader = XmlReader.Create(new StringReader(resultado)))
                    {
                        reader.MoveToContent();
                        while (reader.Read())
                        {
                            if (reader.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }
                            switch (reader.Name)
                            {
                            case "NombreBeneficiario":
                                nombre = reader.ReadElementContentAsString();
                                break;

                            case "PlanCredencial":
                                plan = reader.ReadElementContentAsString();
                                break;
                            }
                        }
                    }
                    afiliado.Name = nombre.Trim() != "" ? nombre.Trim() : Mensajes.Get("AfiIne");
                    afiliado.Plan = plan.Trim();
                }
            }
            catch (Exception ex)
            {
                afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", credencial + ";" + matricula, string.Empty);
            }
            return(afiliado);
        }
Esempio n. 6
0
        public Afiliado Eligibilidad(string crecencial)
        {
            try
            {
                crecencial = "28133584/1";
                var posicion = crecencial.IndexOf("/");
                if (posicion < 0)
                {
                    return(new Afiliado {
                        Name = string.Empty, Plan = string.Empty, HasError = true, Error = new Error {
                            Mensaje = "Credencial con formato incorrecto"
                        }
                    });
                }

                //armado del xml de solicitud
                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("BOREAL");
                    writer.WriteStartElement("Mensaje");
                    writer.WriteElementString("Canal", "ID");
                    writer.WriteElementString("SitioEmisor", "CMSws");
                    writer.WriteElementString("Empresa", "BOREAL");
                    writer.WriteStartElement("Receptor");
                    writer.WriteElementString("Nombre", "BOREAL");
                    writer.WriteElementString("ID", "222023");
                    writer.WriteElementString("Tipo", "IIN");
                    writer.WriteEndElement();
                    writer.WriteStartElement("MsgTipo");
                    writer.WriteElementString("Tipo", "ZQI");
                    writer.WriteElementString("Evento", "Z01");
                    writer.WriteElementString("Estructura", "ZQI_Z01");
                    writer.WriteEndElement();
                    writer.WriteElementString("MsgEntorno", "P");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Seguridad");
                    writer.WriteElementString("Usuario", "cmsws");
                    writer.WriteElementString("Clave", _clave);
                    writer.WriteEndElement();
                    writer.WriteStartElement("Prestador");
                    writer.WriteElementString("PrestadorId", "30543364610");
                    writer.WriteElementString("PrestadorNombre", "");
                    writer.WriteElementString("PrestadorTipoIdent", "CU");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Afiliado");
                    writer.WriteElementString("AfiliadoNroCredencial", crecencial.Substring(0, posicion));
                    writer.WriteElementString("AfiliadoGf", crecencial.Substring(posicion + 1));
                    writer.WriteElementString("TipoIdentificador", "HC");
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                var mensajexml = output.ToString();
                mensajexml = mensajexml.Replace(" />", "/>");
                mensajexml = mensajexml.Substring(39);
                mensajexml = HttpUtility.HtmlDecode(mensajexml);

                var resultado = _objBoreal.ExecuteAsync(HttpUtility.HtmlDecode(mensajexml)).Result;

                logResult(mensajexml, resultado.Egresoxml, "E");

                var plan     = "";
                var afiliado = "";

                using (var reader = XmlReader.Create(new StringReader(resultado.Egresoxml)))
                {
                    reader.MoveToContent();
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        switch (reader.Name)
                        {
                        case "AfiliadoPlanDes":
                            plan = reader.ReadElementContentAsString();
                            break;

                        case "AfiliadoNombre":
                            afiliado = reader.ReadElementContentAsString();
                            break;
                        }
                    }
                }
                return(new Afiliado {
                    Name = afiliado, Plan = plan
                });
            }
            catch (Exception ex)
            {
                var afi = new Afiliado {
                    HasError = true
                };
                afi.SetError(GetType().Name, 0, ex.Message, ex.InnerException?.ToString() ?? string.Empty, crecencial, string.Empty);
                return(afi);
            }
        }
Esempio n. 7
0
        public Afiliado Elegibilidad(string credencial)
        {
            credencial = "0841233/00";

            string cadena;
            string plan;
            var    afiliado = new Afiliado();

            try
            {
                var cred = credencial.Split('/');
                if (cred.Length > 1)
                {
                    var output = @"MSH|^~\{|TRIT0100M|TRIT00999999|SANCOR_SALUD|SANCOR_SALUD^604940^IIN|";
                    output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQ^Z01^ZQI_Z01|05091908480623465897|P|2.4|||NE|AL|ARG";
                    output += Environment.NewLine;
                    output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||22^CU|";
                    output += Environment.NewLine;
                    output += "PID|||" + cred[0] + "^" + cred[1] + "^^SANCOR_SALUD^HC||UNKNOWN";
                    output += Environment.NewLine;

                    Sancor.MessageResponse resultado = _sancor.MessageAsync(8, output).Result;

                    logResult(output.ToString(), resultado.ToString(), "E");

                    if (resultado.resultado.ToString() == "")
                    {
                        return new Afiliado {
                                   Name = Mensajes.Get("AfiIne")
                        }
                    }
                    ;
                    if (resultado.resultado.ToString().Contains("Error ejecutando") || resultado.resultado.ToString().Contains("no se pueden procesar") || resultado.resultado.ToString().Contains("Unable to read data"))
                    {
                        return(new Afiliado {
                            Name = Mensajes.Get("ServidorNoResponde"), HasError = true
                        });
                    }
                    // convertimos respuesta en vector
                    var msHL7 = HL7.DecifraHL7Sancor(resultado.resultado.ToString());
                    var index = msHL7[1].IndexOf("En estos momentos, no se pueden procesar transacciones");
                    if (index > 0)
                    {
                        afiliado.Name = Mensajes.Get("ServidorNoResponde");
                        afiliado.SetError(GetType().Name, 37, Mensajes.Get("ServidorNoResponde"), string.Empty, credencial, string.Empty);
                    }
                    else
                    {
                        if (msHL7[4] != null && msHL7[5] != null)
                        {
                            if (HL7.CampoHL7(msHL7[4], 5, 1) != "UNKNOWN")
                            {
                                cadena = HL7.CampoHL7(msHL7[4], 5, 1) + ", " + HL7.CampoHL7(msHL7[4], 5, 2);
                                plan   = HL7.CampoHL7(msHL7[5], 3, 0);
                            }
                            else
                            {
                                cadena = Mensajes.Get("AfiIne");
                                plan   = "";
                            }
                        }
                        else
                        {
                            cadena = Mensajes.Get("AfiIne");;
                            plan   = "";
                        }
                        afiliado.Name = cadena;
                        afiliado.Plan = plan;
                    }
                }
                else
                {
                    afiliado.Name = "Carnet Mal ingresado";
                    afiliado.Plan = "";
                }
            }
            catch (Exception ex)
            {
                var afi = new Afiliado {
                    HasError = true
                };
                afi.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, credencial, string.Empty);
                return(afi);
            }
            return(afiliado);
        }
Esempio n. 8
0
        public Afiliado Elegibilidad(string credencial, int matricula)
        {
            // credencial = "128990/27";
            var afiliado = new Afiliado();

            try
            {
                string resultado;
                var    xAfiplan  = "";
                var    xAfiliado = "";

                //armado del xml de solicitud
                var output = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("SOLICITUD");

                    writer.WriteStartElement("EMISOR");
                    writer.WriteElementString("ID", "00001-22222");
                    writer.WriteElementString("PROT", "CA_V20");
                    writer.WriteElementString("MSGID", DateTime.Now.ToString("yyyyMMdd") + matricula);//completar
                    writer.WriteElementString("TER", "");
                    writer.WriteElementString("APP", "HMS_CAWEB");
                    writer.WriteElementString("TIME", DateTime.Now.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("SEGURIDAD");
                    writer.WriteElementString("TIPOAUT", "U");
                    writer.WriteElementString("USRID", "7040521");
                    writer.WriteElementString("USRPASS", "DAT_MGR");
                    writer.WriteEndElement();

                    writer.WriteStartElement("OPER");
                    writer.WriteElementString("TIPO", "ELG");
                    writer.WriteElementString("FECHA", DateTime.Now.ToString("yyyy-MM-dd"));
                    writer.WriteElementString("IDASEG", "ACA_SALUD");
                    writer.WriteElementString("IDPRESTADOR", "7040521");
                    writer.WriteEndElement();

                    writer.WriteStartElement("PID");
                    writer.WriteElementString("ID", credencial);
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }
                using (var client = new HttpClient())
                {
                    var url = urlBase + HttpUtility.UrlEncode(output.ToString());
                    client.BaseAddress = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Clear();

                    Task <HttpResponseMessage> response = client.GetAsync(url);
                    resultado = response.Result.Content.ReadAsStringAsync().Result;
                    resultado = HttpUtility.HtmlDecode(resultado);
                }

                logResult(output.ToString(), resultado, "E");

                if (resultado == "")
                {
                    afiliado.Name = Mensajes.Get("AfiIne");
                }
                else
                {
                    using (var reader = XmlReader.Create(new StringReader(resultado)))
                    {
                        reader.MoveToContent();
                        while (reader.Read())
                        {
                            if (reader.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }
                            switch (reader.Name)
                            {
                            case "AFIPLAN":
                                xAfiplan = reader.ReadElementContentAsString();
                                break;

                            case "AFIAPE":
                                xAfiliado = reader.ReadElementContentAsString();
                                break;

                            case "AFINOM":
                                xAfiliado += ", " + reader.ReadElementContentAsString();
                                break;
                            }
                        }
                    }
                    afiliado.Name = xAfiliado != "" ? xAfiliado : Mensajes.Get("AfiIne"); // "Afiliado inexistente o inhabilitado";
                    afiliado.Plan = xAfiplan;
                }
            }
            catch (Exception ex)
            {
                afiliado.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", credencial + ";" + matricula, string.Empty);
            }
            return(afiliado);
        }
Esempio n. 9
0
        public Afiliado Eligibilidad(string credencial)
        {
            string cadena;
            string plan;
            var    afiliado = new Afiliado();

            try
            {
                var output = "MSH|^~\\&|TRIA0100M|TRIA00007160|SWISSHL7|SWISS^800006^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQI^Z01^ZQI_Z01|08050522304540783782|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "PRD|PS^Prestador Solicitante||^^^A||||30543364610^CU|";

                output += Environment.NewLine;
                output += "PID|||" + credencial + "^^^SWISS^HC||UNKNOWN";
                output += Environment.NewLine;

                //Call WebService
                var resultado = _traditum.Send(output);
                logResult(output.ToString(), resultado.ToString(), "E");

                var OSerror = false;
                if (resultado == "")
                {
                    return new Afiliado {
                               Name = Mensajes.Get("AfiIne")
                    }
                }
                ;

                if (resultado.Contains("Error ejecutando") || resultado.Contains("no se pueden procesar") || resultado.Contains("Unable to read data") || resultado.Contains("El cliente encontró el tipo de contenido de respuesta"))
                {
                    OSerror = OsStatus.checkSwiss(true);

                    afiliado.Name = Mensajes.Get("ServidorNoResponde");
                    afiliado.SetError(GetType().Name, 37, Mensajes.Get("ServidorNoResponde"), string.Empty, credencial, string.Empty, OSerror);
                    return(afiliado);
                }
                // convertimos respuesta en vector
                var msHL7 = HL7.DecifraHL7(resultado);
                var index = 0;
                if (msHL7.Length > 1)
                {
                    index = msHL7[1].IndexOf("En estos momentos, no se pueden procesar transacciones");
                }
                else
                {
                    index = 2;
                }
                if (index > 0)
                {
                    OSerror       = OsStatus.checkSwiss(true);
                    afiliado.Name = Mensajes.Get("ServidorNoResponde");
                    afiliado.SetError(GetType().Name, 37, Mensajes.Get("ServidorNoResponde"), string.Empty, credencial, string.Empty, OSerror);
                }
                else
                {
                    OSerror = OsStatus.checkSwiss(false);
                    if (HL7.CampoHL7(msHL7[2], 3, 1) == "B000")
                    {
                        cadena = HL7.CampoHL7(msHL7[4], 5, 1) + ", " + HL7.CampoHL7(msHL7[4], 5, 2);
                        plan   = HL7.CampoHL7(msHL7[5], 2, 0);
                    }
                    else
                    {
                        cadena = Mensajes.Get("AfiIne");
                        plan   = "";
                    }
                    afiliado.Name = cadena;
                    afiliado.Plan = plan;
                }
            }
            catch (Exception ex)
            {
                var afi = new Afiliado {
                    HasError = true
                };
                afi.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, credencial, string.Empty);
                return(afi);
            }
            return(afiliado);
        }
Esempio n. 10
0
        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());
        }