protected void Button1_Click(object sender, EventArgs e)
    {
        Monitoramento monit = new Monitoramento();
        Db_Class      db    = new Db_Class();

        Label1.Text = "";
        if (db.execmd("select count(*) from itens_pagdentista i where i.mesano = '" + TextBox1.Text + "' and i.valor is not null and not exists(select * from  envioMonitGuias e where e.orcamento = i.Orcamento and e.incremento = i.incremento and i.MesAno = e.mesAno)", true) == "0")
        {
            Label1.Text = "não há registro para gerar lote";
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('não há registros para gerar lote')", true);
            return;
        }
        //string retorno = @"C:\temp\3513512015010001.xte"; string nrLote = "1";

        string       nrLote  = monit.griaRegistroLoteMonitoramento(TextBox1.Text, "enio");
        string       retorno = monit.geraMonitoramento(TextBox1.Text, db.getParam("CDRANS"), "enio", nrLote, "G");
        ValidaSchema valid   = new ValidaSchema();

        Label1.Text = valid.validaSchema(retorno, Server.MapPath("") + @"\schema\3.02.00\tissMonitoramentoV3_02_00.xsd");
        if (Label1.Text.Length == 0)
        {
            string msgAux = retorno.Replace(@"\", "_").Replace(":", "");
            Label1.Text = "arquivo gerado com sucesso " + msgAux;
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo gerado com sucesso " + msgAux + " ')", true);
        }
        else
        {
            db.execmd("delete envioMonitGuias where nr_lote = " + nrLote, true);
            db.execmd("delete envioMonitoramento where nr_lote = " + nrLote, true);
            Label1.Text = "Arquivo nao gerado, verifique os erros : " + Label1.Text;
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo nao gerado verifique os erros ')", true);
        }
    }
Example #2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Db_Class db = new Db_Class();

        string sql = "select count(*) from envioMonitoramento where mesano = '" + txtMesAno.Text + "' and nr_lote = " + txtNrLote.Text + " and dt_retorno is not null";

        if (db.execmd(sql, true) != "0")
        {
            lblmsg.Text = "lote não pode ser excluído, já houve processamento de retorno da ANS!";
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('lote não pode ser excluído, já houve processamento de retorno da ANS!')", true);
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('não há registros para gerar lote')", true);
            return;
        }
        sql = "select count(*) from envioMonitoramento where mesano = '" + txtMesAno.Text + "' and nr_lote = " + txtNrLote.Text;
        if (db.execmd(sql, true) == "0")
        {
            lblmsg.Text = "lote não localizado";
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('lote não localizado!')", true);
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('não há registros para gerar lote')", true);
            return;
        }
        sql         = "select dt_envio from envioMonitoramento where mesano = '" + txtMesAno.Text + "' and nr_lote = " + txtNrLote.Text;
        Label1.Text = "confirma a exclusão do lote " + txtNrLote.Text + " do período " + txtMesAno.Text + ". esse lote foi gerado na data de : " + db.execmd(sql, true);
        MultiView1.SetActiveView(View2);
    }
    public string processaQualidadeSIB(string nmArq)
    {
        System.IO.FileInfo arqAux = new System.IO.FileInfo(nmArq);

        XmlDocument arqXml;

        //XmlNamespaceManager xman;
        arqXml = new XmlDocument();
        arqXml.Load(nmArq);
        //xman = new XmlNamespaceManager(arqXml.NameTable);
        //string url = "http://www.ans.gov.br/padroes/tiss/schemas";
        //xman.AddNamespace("ans", url);
        string   cdANS   = arqXml.SelectSingleNode("itemMonitoramento").Attributes[0].InnerText;
        string   erroAnx = arqXml.SelectSingleNode("itemMonitoramento").Attributes[1].InnerText;
        Db_Class db      = new Db_Class();

        if (db.getParam("CDRANS") != cdANS)
        {
            return("Arquivo nao pertence a operadora");
        }
        XmlNodeList beneficiarios  = arqXml.SelectNodes("itemMonitoramento/beneficiarios/beneficiario");
        string      naoLocalizados = "";
        string      erroProc       = "";

        foreach (XmlNode benef in beneficiarios)
        {
            try
            {
                string cco      = benef.SelectSingleNode("cco").InnerText;
                string codBenef = benef.SelectSingleNode("codigoBeneficiario").InnerText;
                if (dbClass.execmd("select count(*) from usuario where codigo_completo = " + codBenef, true) == "0")
                {
                    naoLocalizados += cco + " " + codBenef + "<br/>";
                }
                else
                {
                    db.execmd("insert into qualidadeSib values(" + codBenef + ",'" + arqAux.Name + "','" + cco + "','" + erroAnx + "',getdate())", false);
                }
            }
            catch (Exception ex)
            {
                erroProc += " erro  " + ex.Message + "<br/>";
            }
        }
        Email  mail  = new Email();
        string rsAux = "";

        if (naoLocalizados != "")
        {
            rsAux += "beneficiarios nao localizados : " + naoLocalizados;
            mail.EnviaMailEnio("*****@*****.**", "benef nao localizado qualidade sib", naoLocalizados);
        }
        if (erroProc != "")
        {
            rsAux += "Erros de processamento : " + erroProc;
            mail.EnviaMailEnio("*****@*****.**", "erro processamento qualidade  sib", erroProc);
        }
        return(rsAux);
    }
    public string griaRegistroLoteMonitoramento(string mesAno, string nmLogin)
    {
        Db_Class db     = new Db_Class();
        string   nrLote = db.execmd("select isnull(max(nr_lote),0) + 1 from envioMonitoramento where mesAno = '" + mesAno + "'", true);

        db.execmd("insert into envioMonitoramento (mesAno, nr_lote,  dt_envio, dt_retorno,nmLogin)  values ('" + mesAno + "'," + nrLote + ",getdate(),null,'" + nmLogin + "')", false);
        return(nrLote);
    }
    private bool loteProcessado(string nmArqRejeitado)
    {
        string   mesAno = nmArqRejeitado.Substring(10, 2) + "/" + nmArqRejeitado.Substring(6, 4);
        string   nrLote = nmArqRejeitado.Substring(12, 4);
        Db_Class db     = new Db_Class();

        return(db.execmd("select count(*) from envioMonitoramento  where mesAno = '" + mesAno + "' and nr_lote = " + nrLote + " and dt_retorno is not null", true) != "0");
    }
Example #6
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        Db_Class db = new Db_Class();

        db.execmd("delete manutencaoFS where mesano = '" + txtMesAno.Text + "' and nrlote = " + txtNrLote.Text, false);
        db.execmd("delete envioMonitGuias where mesano = '" + txtMesAno.Text + "' and nr_lote = " + txtNrLote.Text, false);
        db.execmd("delete envioMonitoramento where mesano = '" + txtMesAno.Text + "' and nr_lote = " + txtNrLote.Text, false);
        Label2.Text = "EXCLUSÃO REALIZADA COM SUCESSO!";
    }
    private void gravaRejeicaoLote(string nmArqRejeitado, string codRejeicao)
    {
        Db_Class db     = new Db_Class();
        string   mesAno = nmArqRejeitado.Substring(10, 2) + "/" + nmArqRejeitado.Substring(6, 4);
        string   nrLote = nmArqRejeitado.Substring(12, 4);

        db.execmd("insert into erroMonitoramento select '" + mesAno + "'," + nrLote + ", orcamento,incremento, " + codRejeicao + " from envioMonitGuias where mesAno = '" + mesAno + "' and nr_lote = " + nrLote, false);
        db.execmd("update envioMonitoramento set dt_retorno = getdate() where mesAno = '" + mesAno + "' and nr_lote = " + nrLote, false);
        db.execmd("update envioMonitGuias set aceitoANS = 'N' where mesAno = '" + mesAno + "' and nr_lote = " + nrLote, false);
    }
    private void gravaRejeicaoGuia(string nrGuiaOperadora, string nmArqRejeitado, string codRejeicao)
    {
        Db_Class db     = new Db_Class();
        string   mesAno = nmArqRejeitado.Substring(10, 2) + "/" + nmArqRejeitado.Substring(6, 4);
        string   nrLote = nmArqRejeitado.Substring(12, 4);

        db.execmd("insert into erroMonitoramento select '" + mesAno + "'," + nrLote + ", orcamento,incremento, " + codRejeicao + " from envioMonitGuias e where mesAno = '" + mesAno + "' and nr_lote = " + nrLote + " and orcamento = " + nrGuiaOperadora + " and not exists(select * from erroMonitoramento where mesAno = '" + mesAno + "' and nr_lote = " + nrLote + " and orcamento = " + nrGuiaOperadora + " and incremento = e.incremento and cd_erro = " + codRejeicao + ")", false);

        //db.execmd("update envioMonitGuias set aceitoANS = 'N' where mesAno = '" + mesAno + "' and nr_lote = " + nrLote + " and orcamento = " + nrGuiaOperadora, false);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "";
        string[] parametros = txtMesAnoVlfs.Text.Split('-');
        if (parametros.Length != 2)
        {
            Label1.Text = "Parâmetros inválidos , verifique!";
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Parâmetros inválidos , verifique!')", true);
            return;
            
        }
        string periodo = parametros[0];
        string vlfs = parametros[1];
        Monitoramento monit = new Monitoramento();
        Db_Class db = new Db_Class();
        if (db.execmd("select count(*) from itens_pagdentista i where i.mesano = '" + periodo + "' and i.valor is not null and not exists(select * from  envioMonitGuias e where e.orcamento = i.Orcamento and e.incremento = i.incremento and i.MesAno = e.mesAno and e.aceitoANS = 'S')", true) == "0")
        {

            Label1.Text = "não há registros para gerar lote";
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('não há registros para gerar lote')", true);
            return;
        }

        string nrLote = monit.griaRegistroLoteMonitoramento(periodo,"enio");
        string retorno = monit.geraMonitoramento(periodo, db.getParam("CDRANS"), "enio",nrLote,"G",vlfs);
        ValidaSchema valid = new ValidaSchema();
        //Label1.Text =  valid.validaSchema(retorno, Server.MapPath("") + @"\schema\3.03.03\tissMonitoramentoV3_03_03.xsd");
        Label1.Text = valid.validaSchema(retorno, Server.MapPath("") + @"\schema\1.00.00\tissMonitoramentoV1_00_00.xsd");
        if (Label1.Text.Length == 0)
        {
            Label1.Text = "Arquivo gerado com sucesso " + retorno.Replace(@"\", "_");
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo gerado com sucesso " + retorno.Replace(@"\", "_") + " ')", true);
        }
        else
        {
            Label1.Text = "Arquivo não gerado verifique os erros : " + Label1.Text;
            
            db.execmd("delete envioMonitGuias where mesano = '" + periodo + "' and nr_lote = " + nrLote, true);
            db.execmd("delete envioMonitoramento where mesano = '" + periodo + "' and nr_lote = " + nrLote, true);
            db.execmd("delete manutencaoFS where mesano = '" + periodo + "' and nrLote = " + nrLote, true);
            
            
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo nao gerado verifique os erros ')", true);

        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Monitoramento monit = new Monitoramento();
        Db_Class      db    = new Db_Class();

        string       nrLote  = monit.griaRegistroLoteMonitoramento(TextBox1.Text, "enio");
        string       retorno = monit.geraMonitoramento(TextBox1.Text, db.getParam("CDRANS"), "enio", nrLote, "G");
        ValidaSchema valid   = new ValidaSchema();

        Label1.Text = valid.validaSchema(retorno, Server.MapPath("") + @"\schema\3.02.00\tissMonitoramentoV3_02_00.xsd");
        if (Label1.Text.Length == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo gerado com sucesso " + retorno.Replace(@"\", "_") + " ')", true);
        }
        else
        {
            db.execmd("delete envioMonitGuias where nr_lote = " + nrLote, true);
            db.execmd("delete envioMonitoramento where nr_lote = " + nrLote, true);
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo nao gerado verifique os erros ')", true);
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (TextBox2.Text.Length == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('não há registros para gerar lote')", true);
            // TextBox2.Focus();
            return;
        }
        Monitoramento monit = new Monitoramento();
        Db_Class      db    = new Db_Class();

        string       retorno = monit.geraMonitoramento(TextBox1.Text, db.getParam("CDRANS"), "enio", TextBox2.Text, "R");
        ValidaSchema valid   = new ValidaSchema();

        Label1.Text = valid.validaSchema(retorno, Server.MapPath("") + @"\schema\3.02.00\tissMonitoramentoV3_02_00.xsd");
        if (Label1.Text.Length == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo gerado com sucesso " + retorno.Replace(@"\", "_") + " ')", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Arquivo nao gerado verifiqeu os erros ')", true);
        }
    }
    public string processaRetornoANS(string nmArq)
    {
        XmlDocument         arqXml;
        XmlNamespaceManager xman;

        arqXml = new XmlDocument();
        arqXml.Load(nmArq);
        xman = new XmlNamespaceManager(arqXml.NameTable);
        string url = "http://www.ans.gov.br/padroes/tiss/schemas";

        xman.AddNamespace("ans", url);
        Db_Class db = new Db_Class();

        if (arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:registroANS", xman) == null)
        {
            return("Arquivo nao parece estar no padrao de retorno ANS, nao foi possivel localisar pertence a operadora");
        }
        string cdANS = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:registroANS", xman).InnerText;

        if (db.getParam("CDRANS") != cdANS)
        {
            return("Arquivo nao pertence a operadora");
        }
        string      regANS         = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:registroANS", xman).InnerText;
        XmlNodeList arqRejetado    = arqXml.GetElementsByTagName("ans:arquivoRejeitado");
        string      nmArqRejeitado = "";

        foreach (XmlNode item in arqRejetado)
        {
            nmArqRejeitado = item.SelectSingleNode("ans:nomeArquivo", xman).InnerText;
            if (!loteExiste(nmArqRejeitado))
            {
                return("lote não localizado");
            }
            else
            if (loteProcessado(nmArqRejeitado))
            {
                return("Arquivo já processado anteriormente");
            }
            string codRejeicao = item.SelectSingleNode("ans:codigoRejeicao", xman).InnerText;
            this.gravaRejeicaoLote(nmArqRejeitado, codRejeicao);
        }

        XmlNodeList regRejeitados = arqXml.GetElementsByTagName("ans:registrosRejeitados");

        //testar o arquivo 3299672014120006.XTR
        if (regRejeitados != null)
        {
            nmArqRejeitado = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:Mensagem/ans:ansParaOperadora/ans:resumoProcessamento/ans:nomeArquivo", xman).InnerText;
            if (!loteExiste(nmArqRejeitado))
            {
                return("lote não localizado");
            }
            else

            if (loteProcessado(nmArqRejeitado))
            {
                return("Arquivo já processado anteriormente");
            }
        }
        foreach (XmlNode regRejeitado in regRejeitados)
        {
            XmlNodeList errosGuia = regRejeitado.SelectNodes("ans:errosGuia", xman);
            foreach (XmlNode erro in errosGuia)
            {
                string codRejeicao     = erro.SelectSingleNode("ans:codigoErro", xman).InnerText;
                string nrGuiaOperadora = regRejeitado.SelectSingleNode("ans:numeroGuiaOperadora", xman).InnerText;
                this.gravaRejeicaoGuia(nrGuiaOperadora, nmArqRejeitado, codRejeicao);
            }
        }
        if (nmArqRejeitado != "")
        {
            string mesAno = nmArqRejeitado.Substring(10, 2) + "/" + nmArqRejeitado.Substring(6, 4);
            string nrLote = nmArqRejeitado.Substring(12, 4);

            db.execmd("update envioMonitoramento set dt_retorno = getdate() where mesAno = '" + mesAno + "' and nr_lote = " + nrLote, false);
        }
        return("");
    }
Example #13
0
    public string buscaCep(string cep)
    {
        cep = Util.so_numero(cep);
        string   sql = "";
        Db_Class db  = new Db_Class();

        db.execmd("delete enderecoTemp where cep = " + cep, false);
        string logAux = "log 1,";

        if (cep != "")
        {
            logAux += "log 2,";
            wsCorreios.AtendeClienteClient wscep = new wsCorreios.AtendeClienteClient();
            try
            {
                logAux += "log 3,";
                var dados = wscep.consultaCEP(cep);
                sql = "insert into enderecoTemp values(" +
                      cep + ",'" +
                      dados.end + "','" +
                      dados.bairro + "','" +
                      dados.uf.ToUpper() + "','" +
                      dados.cidade + "','')";
                logAux += "log 4,";
            }
            catch (Exception ex)
            {
                logAux += "log 5,";
                string erro = ex.Message;
                if (erro.Length > 200)
                {
                    erro = erro.Substring(0, 200);
                }
                sql = "insert into enderecoTemp values(" + cep + ",'','','','','" + ex.Message + "')";
                db.execmd(sql, false);
                logAux += "log 6,";
                return(ex.Message + logAux);
            }

            try
            {
                logAux += "log 7,";
                db.execmd(sql, false);
                logAux += "log 7.1,";
            }
            catch (Exception ex)
            {
                logAux += "log 8,";
                string erro = ex.Message;
                if (erro.Length > 200)
                {
                    erro = erro.Substring(0, 200);
                }
                sql = "insert into enderecoTemp values(" + cep + ",'','','','','" + ex.Message + "')";
                db.execmd(sql, false);
                logAux += "log 9,";
                return(ex.Message + logAux);
            }

            return("");
        }
        else
        {
            sql = "insert into enderecoTemp values(" + cep + ",'','','','','cep deve ser informado')";
            db.execmd(sql, false);
            return("cep deve ser informado");
        }
    }
    private bool loteProcessado(string competencia)
    {
        Db_Class db = new Db_Class();

        return(db.execmd("select count(*) from errosQualidadeANS  where mesAno = '" + competencia + "'", true) != "0");
    }
    public string processaRetornoANS(string nmArq)
    {
        XmlDocument         arqXml;
        XmlNamespaceManager xman;

        arqXml = new XmlDocument();
        arqXml.Load(nmArq);
        xman = new XmlNamespaceManager(arqXml.NameTable);
        string url = "http://www.ans.gov.br/padroes/tiss/schemas";

        xman.AddNamespace("ans", url);
        Db_Class db = new Db_Class();

        if (arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:registroANS", xman) == null)
        {
            return("Arquivo nao parece estar no padrao de retorno ANS, nao foi possivel localisar pertence a operadora");
        }
        string cdANS = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:registroANS", xman).InnerText;

        if (db.getParam("CDRANS") != cdANS)
        {
            return("Arquivo nao pertence a operadora");
        }
        string nrLote      = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:identificacaoTransacao/ans:numeroLote", xman).InnerText;
        string competencia = arqXml.SelectSingleNode("ans:mensagemEnvioANS/ans:cabecalho/ans:identificacaoTransacao/ans:competenciaLote", xman).InnerText;

        competencia = competencia.Substring(4, 2) + "/" + competencia.Substring(0, 4);
        if (db.execmd("select count(*) from envioMonitoramento where mesano = '" + competencia + "' and nr_lote = " + nrLote, true) == "0")
        {
            return("lote " + nrLote + " não localizado na competência " + competencia);
        }


        if (loteProcessado(competencia))
        {
            return("Arquivo já processado anteriormente");
        }



        XmlNodeList regRejeitados = arqXml.SelectNodes("ans:mensagemEnvioANS/ans:Mensagem/ans:ansParaOperadora/ans:controleQualidade/ans:guiaAtendimento", xman);

        foreach (XmlNode regRejeitado in regRejeitados)
        {
            try
            {
                string nrGuiaOperadora   = regRejeitado.SelectSingleNode("ans:numeroGuiaOperadora", xman).InnerText;
                string dataProcessamento = regRejeitado.SelectSingleNode("ans:lancamentosRegistradosANS/ans:dataProcessamento", xman).InnerText;

                XmlNodeList ocorrenciasLanc = regRejeitado.SelectNodes("ans:lancamentosCompetencia/ans:lancamento/ans:ocorrenciasLancamento", xman);
                int         cont            = 0;
                foreach (XmlNode ocorrencia in ocorrenciasLanc)
                {
                    cont++;
                    XmlNodeList ItensOcorrencias = ocorrencia.SelectNodes("ans:ocorrencia", xman);
                    foreach (XmlNode ocorrenciaItem in ItensOcorrencias)
                    {
                        string campo  = ocorrenciaItem.SelectSingleNode("ans:identificadorCampo", xman).InnerText;
                        string erro   = ocorrenciaItem.SelectSingleNode("ans:codigoErro", xman).InnerText;
                        string seqAux = db.execmd("select isnull(max(sequencial),0) + 1 from errosQualidadeANS where mesano = '" + competencia + "' and nr_lote = " + nrLote, true);
                        string sql    = "insert into errosQualidadeANS values('" + competencia + "'," + nrLote + "," + nrGuiaOperadora + "," + seqAux + "," + campo + "," + erro + ",getdate(),'')";
                        db.execmd(sql, false);
                        if (erro != "1308") // 1308 guia ja apresentada
                        {
                            db.execmd("update envioMonitGuias set aceitoANS = 'N' where mesAno = '" + competencia + "' and nr_lote = " + nrLote + " and orcamento = " + nrGuiaOperadora, false);
                        }
                    }
                }
                if (cont > 1)
                {
                    return("mais de um nivel ans:ocorrenciasLancamento, precisa adaptar a rotina");
                }

                XmlNodeList itensLancamento = regRejeitado.SelectNodes("ans:lancamentosCompetencia/ans:lancamento/ans:itensLancamento/ans:procedimentoItemAssistencial", xman);

                foreach (XmlNode procedimentoItemAssistencial in itensLancamento)
                {
                    //XmlNodeList procedimentoItemAssistencial = ItemLancamento.SelectNodes("ans:procedimentoItemAssistencial", xman);
                    foreach (XmlNode ocorrencia in procedimentoItemAssistencial.SelectNodes("ans:ocorrenciasProcedimentoItemAssistencial/ans:ocorrencia", xman))
                    {
                        string campo        = ocorrencia.SelectSingleNode("ans:identificadorCampo", xman).InnerText;
                        string erro         = ocorrencia.SelectSingleNode("ans:codigoErro", xman).InnerText;
                        string procedimento = procedimentoItemAssistencial.SelectSingleNode("ans:procedimento/ans:codigoProcedimento", xman).InnerText;
                        string denteRegiao  = "";
                        if (procedimentoItemAssistencial.SelectSingleNode("ans:denteRegiao/ans:codDente", xman) != null)
                        {
                            denteRegiao += "Dente : " + procedimentoItemAssistencial.SelectSingleNode("ans:denteRegiao/ans:codDente", xman).InnerText;
                        }
                        if (procedimentoItemAssistencial.SelectSingleNode("ans:denteRegiao/ans:codRegiao", xman) != null)
                        {
                            denteRegiao += "região : " + procedimentoItemAssistencial.SelectSingleNode("ans:denteRegiao/ans:codRegiao", xman).InnerText;
                        }
                        if (procedimentoItemAssistencial.SelectSingleNode("ans:denteFace", xman) != null)
                        {
                            denteRegiao += "Face : " + procedimentoItemAssistencial.SelectSingleNode("ans:denteFace", xman).InnerText;
                        }
                        denteRegiao += " procedimento : " + procedimento;
                        string seqAux = db.execmd("select isnull(max(sequencial),0) + 1 from errosQualidadeANS where mesano = '" + competencia + "' and nr_lote = " + nrLote, true);
                        string sql    = "insert into errosQualidadeANS values('" + competencia + "'," + nrLote + "," + nrGuiaOperadora + "," + seqAux + "," + campo + "," + erro + ",getdate(),'" + denteRegiao + "')";

                        db.execmd(sql, false);
                        if (erro != "1308") // 1308 guia ja apresentada
                        {
                            db.execmd("update envioMonitGuias set aceitoANS = 'N' where mesAno = '" + competencia + "' and nr_lote = " + nrLote + " and orcamento = " + nrGuiaOperadora, false);
                        }
                    }
                }
                //this.gravaRejeicaoGuia(nrGuiaOperadora, nmArqRejeitado, codRejeicao);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            XmlNodeList errosItem = regRejeitado.SelectNodes("ans:errosItensGuia", xman);
            foreach (XmlNode erroItem in errosItem)
            {
                try
                {
                    string codRejeicao     = erroItem.SelectSingleNode("ans:relacaoErros/ans:codigoErro", xman).InnerText;
                    string nrGuiaOperadora = regRejeitado.SelectSingleNode("ans:numeroGuiaOperadora", xman).InnerText;
                    //this.gravaRejeicaoGuia(nrGuiaOperadora, nmArqRejeitado, codRejeicao);
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
        if ("" != "")
        {
            string mesAno = ""; // nmArqRejeitado.Substring(10, 2) + "/" + nmArqRejeitado.Substring(6, 4);
            //string nrLote = ""; //nmArqRejeitado.Substring(12, 4);

            db.execmd("update envioMonitoramento set dt_retorno = getdate() where mesAno = '" + mesAno + "' and nr_lote = " + nrLote, false);
        }
        return("");
    }