Exemplo n.º 1
0
        private bool Anular(AnulacionOS anulacionOs)
        {
            var query = "";

            try
            {
                query  = "UPDATE Autorizaciones SET Estado_Autorizacion='Anulada', NESTADO=1, DFEC_ESTADO=SYSDATE, CCOD_ANULACION='" + anulacionOs.CodAnulacion + "', dfec_anulacion=SYSDATE";
                query += " WHERE NID_AUTORIZACION=" + anulacionOs.IdAuth;

                var c = new Connection();
                c.QueryNoResult(query);

                query = "UPDATE Autorizaciones_Detalle SET Estado_Autorizacion='Anulada' WHERE Estado_Autorizacion='Autorizada' AND NID_AUTORIZACION=" + anulacionOs.IdAuth;
                c.QueryNoResult(query);

                return(true);
            }
            catch (Exception ex)
            {
                var errores = new Errores {
                    HasError = true
                };
                errores.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, anulacionOs, query);
                return(false);
            }
        }
Exemplo n.º 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.DecifraHL7(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), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Exemplo n.º 3
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|TRIA00000003|SANCOR_SALUD|SANCOR_SALUD^604940^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQA^Z04^ZQA_Z04|18071613545151234567890|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "ZAU||" + sIdInternoAut;
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||96065^PR|";


                output += Environment.NewLine;
                output += "PID|||" + model.Credencial + "^^^SANCOR_SALUD^HC^SANCOR_SALUD||UNKNOWN";

                Sancor.MessageResponse resultado = _sancor.MessageAsync(8, output).Result;
                logResult(output.ToString(), resultado.ToString(), "D");

                if (resultado.resultado.Substring(0, 4) == "MSH|")
                {
                    return(SetAnulacionOs(resultado.ToString(), model));
                }
                anulacionOs.SetError(GetType().Name, 0, resultado.resultado.ToString(), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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(),
                };

                var sEstado = "";

                using (var reader = XmlReader.Create(new StringReader(data)))
                {
                    reader.MoveToContent();
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        switch (reader.Name)
                        {
                        case "IDTRAN":
                            anulacionOs.CodAnulacion = reader.ReadElementContentAsString();
                            break;

                        case "STATUS":
                            sEstado = reader.ReadElementContentAsString();
                            break;

                        case "AFIPLAN":
                            break;

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

                        case "AFINOM":
                            //sAfiliadoNom = sAfiliadoNom + ", " + reader.ReadElementContentAsString();
                            break;

                        case "IDAUT":
                            //sNroAutorizacion = reader.ReadElementContentAsString();
                            break;
                        }
                    }
                }

                anulacionOs.Estado = sEstado; //OK - Anular; Cualquier otra cosa; No hacer Nada
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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(),
                };

                using (var reader = XmlReader.Create(new StringReader(data)))
                {
                    reader.MoveToContent();
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        switch (reader.Name)
                        {
                        case "SystemTrace":
                            anulacionOs.CodAnulacion = reader.ReadElementContentAsString();
                            anulacionOs.Estado       = "Anulada";
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Exemplo n.º 9
0
        public AutorizacionVer Anular(int authId)
        {
            var anulacionOs     = new AnulacionOS();
            var autorizacionVer = new AutorizacionVer();

            try
            {
                var    auth  = new AutorizacionRepository();
                Anular model = auth.GetAuthDataById(authId);

                switch (model.OSId)
                {
                case 114:    //Swiss Medical
                    var swiss = new OSSwiss();
                    anulacionOs = swiss.Anular(model);
                    break;

                case 132:
                    var acaSalud = new OSAcaSalud();
                    anulacionOs = acaSalud.AnularAsync(model).Result;
                    break;

                case 137:
                case 192:
                    var boreal = new OSBoreal();
                    anulacionOs = boreal.Anular(model);
                    break;

                case 140:
                    var medife = new OSMedife();
                    anulacionOs = medife.Anular(model);
                    break;

                case 181:
                    var redSeguros = new OSRedSeguros();
                    anulacionOs = redSeguros.Anular(model);
                    break;

                case 148:
                    var sancor = new OSSancor();
                    anulacionOs = sancor.Anular(model);
                    break;

                case 141:     //Hay que cambiar por la correspondiente
                    var os = new OSPatrones();
                    anulacionOs = os.Anular(model);
                    break;
                }
                if (!anulacionOs.HasError)
                {
                    if (Anular(anulacionOs))
                    {
                        return(GetAuthBy(authId));
                    }
                    //todo mapear objeto
                    //return Al menos retornar codigo de anulacion
                }
                else
                {
                    autorizacionVer.HasError = anulacionOs.HasError;
                    autorizacionVer.Error    = anulacionOs.Error;
                }
            }
            catch (Exception ex)
            {
                autorizacionVer.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", authId, string.Empty);
            }
            return(autorizacionVer);
        }
Exemplo n.º 10
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(),
                };

                var sEstado  = " ";
                var fechaint = "";

                using (var reader = XmlReader.Create(new StringReader(data)))
                {
                    reader.MoveToContent();
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        switch (reader.Name)
                        {
                        case "AutCod":
                            anulacionOs.CodAnulacion = reader.ReadElementContentAsString();
                            break;

                        case "AutEstadoId":
                            sEstado = reader.ReadElementContentAsString();
                            sEstado = sEstado == "B000" ? "OK" : "NO";
                            break;

                        case "Year":
                            fechaint = "20" + reader.ReadElementContentAsString() + "-";
                            break;

                        case "Mes":
                            fechaint += reader.ReadElementContentAsString() + "-";
                            break;

                        case "Dia":
                            fechaint += reader.ReadElementContentAsString() + " ";
                            break;

                        case "Hora":
                            fechaint += reader.ReadElementContentAsString() + ":";
                            break;

                        case "Minutos":
                            fechaint += reader.ReadElementContentAsString() + ":";
                            break;

                        case "Seg":
                            fechaint         += reader.ReadElementContentAsString();
                            anulacionOs.Fecha = fechaint;
                            break;
                        }
                    }
                }

                if (sEstado != "OK")
                {
                    anulacionOs.HasError      = true;
                    anulacionOs.Error.Mensaje = sEstado;
                }
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
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);
        }