예제 #1
0
        public AnulacionOS Anular(Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = "MSH|^~\\&|TRIA0100M|TRIA00007160|MEDIFE|MEDIFE^222222^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQA^Z04^ZQA_Z02|10121509341187324160|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "ZAU||" + sIdInternoAut;
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||30543364610^CU|";
                output += Environment.NewLine;
                output += "PID|||" + model.Credencial + "^^^MEDIFE^HC^MEDIFE||UNKNOWN";

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

                if (resultado.Substring(0, 4) == "MSH|")
                {
                    return(SetAnulacionOs(resultado, model));
                }
                anulacionOs.SetError(GetType().Name, 0, resultado, string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
예제 #2
0
        private AnulacionOS SetAnulacionOs(string data, Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                anulacionOs = new AnulacionOS
                {
                    IdAuth  = model.AuthId.ToString(),
                    Nestado = "1",
                    Fecha   = DateTime.Now.ToString(),
                };

                // convertimos respuesta en vector
                var msHL7 = HL7.DecifraHL7Sancor(data);

                // número de la transacción tercera línea - ZAU
                anulacionOs.CodAnulacion = HL7.CampoHL7(msHL7[2], 2, 0);

                // resultado autorización tercera línea - ZAU
                var sEstado = HL7.CampoHL7(msHL7[2], 3, 1);

                anulacionOs.Estado = sEstado == "B000" ? "OK" : "NO";
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        public AnulacionOS Anular(Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("Mensaje");
                    writer.WriteStartElement("EncabezadoMensaje");
                    writer.WriteElementString("VersionMsj", "ACT20");
                    writer.WriteElementString("NroReferenciaCancel", sIdInternoAut);
                    writer.WriteElementString("TipoMsj", "OL");
                    writer.WriteElementString("TipoTransaccion", "04A");
                    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.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                var resultado = service.ExecuteFileTransactionSLAsync("0000", output.ToString()).Result;
                logResult(output.ToString(), resultado.ToString(), "A");

                if (resultado != "")
                {
                    return(SetAnulacionOs(resultado, model));
                }

                anulacionOs.SetError(GetType().Name, 0, Mensajes.Get("AnulFail"), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty);
            }

            return(anulacionOs);
        }
예제 #6
0
        public AnulacionOS Anular(Anular model)
        {
            const string url         = "http://ws1.rsmprestadores.com/anular.php?cuit=30-54336461-0&clave=4610&numorden=";
            var          anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);
                var request       = WebRequest.Create(url + sIdInternoAut);
                var response      = request.GetResponse();
                var dataStream    = response.GetResponseStream();
                var reader        = new StreamReader(dataStream);
                var resultado     = reader.ReadToEnd();
                reader.Close();
                response.Close();

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

                if (resultado.Substring(0, 3) == "ERR")
                {
                    anulacionOs.SetError(GetType().Name, 0, resultado, string.Empty, model, string.Empty);
                }
                else
                {
                    anulacionOs = new AnulacionOS
                    {
                        IdAuth       = model.AuthId.ToString(),
                        Nestado      = "1",
                        Fecha        = DateTime.Now.ToString(),
                        CodAnulacion = model.AuthId.ToString(),
                        Estado       = "Ok"
                    };
                }
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
예제 #7
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);
        }
예제 #8
0
        public AnulacionOS Anular(Anular model)
        {
            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                //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", "ZQA");
                    writer.WriteElementString("Evento", "Z04");
                    writer.WriteElementString("Estructura", "ZQA_Z02");
                    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("Autorizacion");
                    writer.WriteElementString("AutCod", "");
                    writer.WriteElementString("AutEstadoId", "");
                    writer.WriteElementString("AutObs", "");
                    writer.WriteElementString("AutCodAnulacion", sIdInternoAut);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                var mensajexml = output.ToString();
                mensajexml = mensajexml.Replace(" />", "/>");

                try
                {
                    var resultado = _objBoreal.ExecuteAsync(HttpUtility.HtmlDecode(mensajexml)).Result;
                    logResult(mensajexml, resultado.Egresoxml, "A");

                    return(SetAnulacionOs(resultado.ToString(), model));

                    //Todo: Si vuelve Vacio error, ver como tratar
                }
                catch (Exception ex)
                {
                    var anulacionOs = new AnulacionOS();
                    anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
                    return(anulacionOs);
                }
            }
            catch (Exception ex)
            {
                var anulacionOs = new AnulacionOS();
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
                return(anulacionOs);
            }
        }
예제 #9
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);
        }
예제 #10
0
        public async Task <AnulacionOS> AnularAsync(Anular model)
        {
            var    anulacionOs = new AnulacionOS();
            string resultado;

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = new StringBuilder();
                using (var 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") + model.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", "ATR");
                    writer.WriteElementString("FECHA", DateTime.Now.ToString("yyyy-MM-dd"));
                    writer.WriteElementString("IDASEG", "ACA_SALUD");
                    writer.WriteElementString("IDPRESTADOR", "7040521");
                    writer.WriteElementString("TIPOIDANUL", "IDTRAN");
                    writer.WriteElementString("IDANUL", sIdInternoAut);
                    writer.WriteEndElement();

                    writer.WriteStartElement("PID");
                    writer.WriteElementString("TIPOID", "CODIGO_AFI");
                    writer.WriteElementString("ID", model.Credencial);
                    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 = await response.Result.Content.ReadAsStringAsync();

                    resultado = HttpUtility.HtmlDecode(resultado);
                }

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

                if (resultado != "")
                {
                    return(SetAnulacionOs(resultado, model));
                }

                anulacionOs.SetError(GetType().Name, 0, Mensajes.Get("AnulFail"), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty);
            }

            return(anulacionOs);
        }
예제 #11
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);
        }
예제 #12
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);
        }