Jump to content
Fivewin Brasil

SNGPC do zero - Preciso de ajuda


Ariston Santos

Recommended Posts

Olá pessoal.

Preciso gerar e transmitir os XMLs ao Webservice do SNGPC mas não tenho nada.

Já notei em alguns tópicos aqui que tem alguns colegas que já desenvolveram esse tipo de solução.

Gostaria de saber se podem compartilhar aqui algum código que possa me ajudar a iniciar esse projeto.

Grato.

Link to comment
Share on other sites

olá achei isso, veja se te ajuda.

William

//
// Recuperar inventario da ANVISA para o SNGPC.
// Manoel Angeiras, 2011
//

#define STRU_TMP { { "NUMMS    ", "C", 13, 0 }, { "NOMEPRO  ", "C", 46, 0 },;
                   { "NUMLOTE  ", "C", 20, 0 }, { "QTDLOTE  ", "N",  6, 0 } }

***************
FUNCTION MAIN()
***************
   if !InternetOK()
      Alert("Sem conexão com a Internet. Verifique...")
      return .F.
   endif
   //
   // ABERTURA DAS FUNCOES PARA WEBSERVICE DO XHARBOUR
   //
   try
      http := CreateObject( "MSXML2.XMLHTTP" )
   catch
      try
         http := CreateObject( "MSXML2.XMLHTTP" )
      catch
         Alert("Erro na criação do objeto MSXML2.XMLHTTP : " + Ole2TxtError())
      end
   end

   //
   // AS COMUNICACOES SEGUINTES FORAM BASEADAS NA MINHA OBSERVACAO DE LOGIN
   // MANUAL NO SITE DA ANVISA, USANDO UM WEB DEBUGGER
   //

   //
   // VERIFICAR A DISPONIBILIDADE DO SITE DA ANVISA
   //
   cRet := RequestOpen()

   //
   // CONFIGURAR E LER COOKIE CRIADO POR ESSA COMUNICACAO
   //
   cCookie := LerCookie()

   //
   // FAZER LOGIN NO SITE ANVISA
   //
   cRet := Login( alltrim( cCookie ), SEU_EMAIL, SUA_SENHA )
   memowrit("lerinv.txt", cRet)

   //
   // SALVEI A RESPOSTA EM .TXT, MAS  NA VERDADE UM XML, ACHO QUE Dµ PRA LER
   // COM A CLASSE TxmlDocument
   //
   cEmpresa := cRT := cNome := ""
   AchaToken("lerinv.txt", @cEmpresa, @cRT, @cNome)
   if empty( cEmpresa )
      Alert("Problema na identificacao da empresa. Verifique...")
      return .F.
   endif
   if empty( cRT )
      Alert("Problema na identificacao do Responsavel Tecnico. Verifique")
      return .F.
   endif

   //
   // SELECIONA A EMPRESA. TEM AQUI UMA LIMITACAO : O RESPONSAVEL TECNICO SO
   // PODE ESTAR LIGADO A UMA EMPRESA ( FARMACEUTICO NO INTERIOR DOS ESTADOS
   // PODEM CONTROLAR AT DUAS FARMACIAS/DROGARIAS ). SE POSSUIR MAIS DE UMA
   // EMPRESA, NAO LE CORRETAMENTE
   //
   cRet := SelEmpresa( cCookie, cEmpresa, cRT, cNome )
   memowrit("lerinv.txt", cRet)
   cID1 := AchaToken2("lerinv.txt")

   //
   // SELECIONA RESPONSAVEL TECNICO
   //
   cRet := SelRT( cCookie, cEmpresa, cRT, cNome, cID1 )

   //
   // LER MENU DO SITE ANVISA
   //
   LerMenu( cCookie )

   //
   // LER INVENTARIO. ACHO QUE ESSE PASSO PODE SER DESCONSIDERADO
   //
   cRet := VerInv( cCookie )
   memowrit("verinv.txt", cRet)

   //
   // CHAMO A TELA DE FINALIZACAO DO INVENTARIO, QUE CONTEM OS PRODUTOS COM OS
   // SEUS LOTES
   //
   cRet := FimInv( cCookie )
   memowrit("lotesinv.txt", cRet)

   //
   // GRAVO O RESULTADO EM UM DBF PARA PROCESSAR DEPOIS
   //
   lRet := CriaDBF( "lotesinv.txt" )

RETURN lRet

*****************************
STATIC FUNCTION REQUESTOPEN()
*****************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "GET", "http://homologacao.anvisa.gov.br/sngpc/", .F. )
   http:SetRequestHeader( "Accept", "*/*" )
   http:SetRequestHeader( "Accept-Language", "pt-br" )
   http:SetRequestHeader( "Accept-Encoding", "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
//
// ENDERECOS DE PRODUCAO
//
// http:Open( "GET", "https://sngpc.anvisa.gov.br/", .F. )
// http:SetRequestHeader( "Accept", "*/*" )
// http:SetRequestHeader( "Accept-Language", "pt-br" )
// http:SetRequestHeader( "Accept-Encoding", "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )

   http:send()
   response  := http:statusText
RETURN response

***************************
STATIC FUNCTION LERCOOKIE()
***************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "GET", "http://homologacao.anvisa.gov.br/sngpc/includes/fundo.asp", .F. )
   http:SetRequestHeader( "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*" )
   http:SetRequestHeader( "Referer", "http://homologacao.anvisa.gov.br/sngpc/" )
   http:SetRequestHeader( "Accept-Language", "pt-br" )
   http:SetRequestHeader( "Accept-Encoding", "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "GET", "https://sngpc.anvisa.gov.br/includes/fundo.asp", .F. )
// http:SetRequestHeader( "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*" )
// http:SetRequestHeader( "Referer", "https://sngpc.anvisa.gov.br/" )
// http:SetRequestHeader( "Accept-Language", "pt-br" )
// http:SetRequestHeader( "Accept-Encoding", "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )

   http:send()
   response  := http:getResponseHeader("Set-Cookie")
RETURN response

************************************************
STATIC FUNCTION LOGIN( cCookie, memail, msenha )
************************************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/login.asp" )
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Keep-Alive"      , "115" )
   http:SetRequestHeader( "Cookie"          , cCookie )
   http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "POST", "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/login.asp" )
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Keep-Alive"      , "115" )
// http:SetRequestHeader( "Cookie"          , cCookie )
// http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

   http:send( "email=" + memail + "&senha=" + msenha + "&Entrar=Entrar" )
   response  := http:responseText
RETURN response

******************************************************
STATIC FUNCTION SELEMPRESA( cCookie, cID, cRT, cNome )
******************************************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp")
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Keep-Alive"      , "115" )
   http:SetRequestHeader( "Cookie"          , cCookie )
   http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "POST", "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp")
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Keep-Alive"      , "115" )
// http:SetRequestHeader( "Cookie"          , cCookie )
// http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

   http:send( "hidPasso=1&hidPessoaRepresentada=" + cID +;
                        "&hidTipoPessoaRepresentada=&hidPessoaFisica=" + cRT +;
                        "&hidNomeEmpresa=" + cNome +;
                        "&hidRepresentante=&hiComboRepresentacao=&hiComboRepresenta=" + cID +;
                        "&Representa=&Representacao=&IDPESSOAREPRESENTADA=" + cID )
   response  := http:responseText
RETURN response

*******************************************************
STATIC FUNCTION SELRT( cCookie, cID, cRT, cNome, cID1 )
*******************************************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp")
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Keep-Alive"      , "115" )
   http:SetRequestHeader( "Cookie"          , cCookie )
   http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "POST", "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp")
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Keep-Alive"      , "115" )
// http:SetRequestHeader( "Cookie"          , cCookie )
// http:SetRequestHeader( "Content-Type"    , "application/x-www-form-urlencoded" )

   http:send( "hidPasso=2&hidPessoaRepresentada=" + cID                 +;
                        "&hidTipoPessoaRepresentada=1"                  +;
                        "&hidPessoaFisica=" + cRT                       +;
                        "&hidNomeEmpresa=" + cNome                      +;
                        "&hidRepresentante=" + cID1                     +;
                        "&hiComboRepresentacao=RESPONS%C1VEL+T%C9CNICO" +;
                        "&hiComboRepresenta=" + cID                     +;
                        "&Representa=" + cID                            +;
                        "&Representacao="                               +;
                        "&IDPESSOAREPRESENTADA=" + cID                  +;
                        "&CBOTIPOS=1" )

   response  := http:responseText
RETURN response

**********************************
STATIC FUNCTION LERMENU( cCookie )
**********************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "GET", "http://homologacao.anvisa.gov.br/sngpc/includes/menu.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/AcessoPersistir.asp")
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Cookie"          , cCookie )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "GET", "https://sngpc.anvisa.gov.br/includes/menu.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/AcessoPersistir.asp")
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Cookie"          , cCookie )

   http:send()
   response  := http:responseText
RETURN response

*********************************
STATIC FUNCTION VERINV( cCookie )
*********************************
//
// ENDERECO DE HOMOLOGACAO
//
   http:Open( "GET", "http://homologacao.anvisa.gov.br/sngpc/sngpc_frmVisualizaInventario.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/menu.asp")
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Cookie"          , cCookie )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "GET", "https://sngpc.anvisa.gov.br/sngpc_frmVisualizaInventario.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/menu.asp")
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Cookie"          , cCookie )

   http:send()
   response  := http:responseText
RETURN response

*********************************
STATIC FUNCTION FIMINV( cCookie )
*********************************
//
// ENDERECO HOMOLOGACAO
//
   http:Open( "GET", "http://homologacao.anvisa.gov.br/sngpc/sngpc_frmFinalizaInventario.asp", .F. )
   http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
   http:SetRequestHeader( "Referer"         , "http://homologacao.anvisa.gov.br/sngpc/includes/menu.asp")
   http:SetRequestHeader( "Accept-Language" , "pt-br" )
   http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
   http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
   http:SetRequestHeader( "Host"            , "homologacao.anvisa.gov.br" )
   http:SetRequestHeader( "Connection"      , "Keep-Alive" )
   http:SetRequestHeader( "Cookie"          , cCookie )

//
// ENDERECO DE PRODUCAO
//
// http:Open( "GET", "https://sngpc.anvisa.gov.br/sngpc_frmFinalizaInventario.asp", .F. )
// http:SetRequestHeader( "Accept"          , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" )
// http:SetRequestHeader( "Referer"         , "https://sngpc.anvisa.gov.br/includes/menu.asp")
// http:SetRequestHeader( "Accept-Language" , "pt-br" )
// http:SetRequestHeader( "Accept-Encoding" , "gzip, deflate" )
// http:SetRequestHeader( "User-Agent"      , "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; BTRS25991; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)" )
// http:SetRequestHeader( "Host"            , "sngpc.anvisa.gov.br" )
// http:SetRequestHeader( "Connection"      , "Keep-Alive" )
// http:SetRequestHeader( "Cookie"          , cCookie )

   http:send()
   response  := http:responseText
RETURN response

**************************************************
STATIC FUNCTION ACHATOKEN( cFile, cEmp, cRT, cRS )
**************************************************
   local aLines, nHand2, nA, nB, nPos, cRet := ""

   aLines  := {}
   nHand2  := fopen( cFile )
   cLine   := ""
   while HB_FReadLine( nHand2, @cLine ) == 0
      aadd( aLines, upper( cLine ) )
   enddo
   aadd( aLines, cLine )
   fClose( nHand2 )

   for nA := 1 to len( aLines )
      if ( nPos := at( '<INPUT TYPE="HIDDEN" NAME="HIDPESSOAFISICA" VALUE="', aLines[nA] ) ) # 0
         for nB := nPos+51 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # '"'
               cRT += substr( aLines[ nA ], nB, 1 )
            else
               exit
            endif
         next
      endif
      if ( nPos := at( "<OPTION VALUE='", aLines[nA] ) ) # 0
         for nB := nPos+15 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "<"
               cEmp += substr( aLines[ nA ], nB, 1 )
            else
               exit
            endif
         next
      endif
   next
   x1 := x2 := ""
   lOK:= .F.
   for nA := 1 to len( cEmp )
      if substr( cEmp, nA, 1 ) # "'" .and. !lOk
         x1 += substr( cEmp, nA, 1 )
      else
         if !lOK
            nA++
            lOk := .T.
         else
            x2 += substr( cEmp, nA, 1 )
         endif
      endif
   next
   cEmp := x1
   cRS  := strtran( x2, " ", "+" )
RETURN

***********************************
STATIC FUNCTION ACHATOKEN2( cFile )
***********************************
   local aLines, nHand2, nA, nB, nPos, cRet := ""

   aLines  := {}
   nHand2  := fopen( cFile )
   cLine   := ""
   while HB_FReadLine( nHand2, @cLine ) == 0
      aadd( aLines, alltrim( upper( cLine ) ) )
   enddo
   aadd( aLines, cLine )
   fClose( nHand2 )

   for nA := 1 to len( aLines )
      if ( nPos := at( "<OPTION ID='", aLines[nA] ) ) # 0
         for nB := nPos+12 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "'"
               cRet += substr( aLines[ nA ], nB, 1 )
            else
               exit
            endif
         next
      endif
   next
RETURN cRet

********************************
STATIC FUNCTION CRIADBF( cFile )
********************************
   local aLines, nHand2, nA, nB, nPos, cRet := ""

   aLines  := {}
   nHand2  := fopen( cFile )
   cLine   := ""
   while HB_FReadLine( nHand2, @cLine ) == 0
      aadd( aLines, alltrim( upper( cLine ) ) )
   enddo
   aadd( aLines, cLine )
   fClose( nHand2 )

   lMS := lNome := lLote := lQtd := .F.
   cMS := cNome := cLote := cQtd := ""
   aInv:= {}
   for nA := 1 to len( aLines )
      //
      // LE O MS DO PRODUTO
      //
      if ( nPos := at( '<TD WIDTH="17%" CLASS="SEMBORDA" HEIGHT="20">', aLines[nA] ) ) # 0
         for nB := nPos+45 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "<"
               cMS += substr( aLines[ nA ], nB, 1 )
               lMS := .T.
            else
               exit
            endif
         next
      endif
      //
      // LE O NOME DO PRODUTO
      //
      if ( nPos := at( '<TD WIDTH="50%" CLASS="SEMBORDA" HEIGHT="20">', aLines[nA] ) ) # 0
         for nB := nPos+45 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "<"
               cNome += substr( aLines[ nA ], nB, 1 )
               lNome := .T.
            else
               exit
            endif
         next
      endif
      //
      // LE O LOTE DO PRODUTO
      //
      if ( nPos := at( '<TD WIDTH="18%" CLASS="SEMBORDA" HEIGHT="20">', aLines[nA] ) ) # 0
         for nB := nPos+45 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "<"
               cLote += substr( aLines[ nA ], nB, 1 )
               lLote := .T.
            else
               exit
            endif
         next
      endif
      //
      // LE A QUANTIDADE DO PRODUTO
      //
      if ( nPos := at( '<TD WIDTH="15%" CLASS="SEMBORDA" HEIGHT="20">', aLines[nA] ) ) # 0
         for nB := nPos+45 to len( aLines[ nA ] )
            if substr( aLines[ nA ], nB, 1 ) # "<"
               cQtd += substr( aLines[ nA ], nB, 1 )
               lQtd := .T.
            else
               exit
            endif
         next
      endif
      if lMS .and. lNome .and. lLote .and. lQtd
         aadd( aInv, { cMS, cNome, cLote, cQtd } )
         lMS := lNome := lLote := lQtd := .F.
         cMS := cNome := cLote := cQtd := ""
      endif
   next
   if empty( aInv )
      return .F.
   endif
   dbCreate( "TEMP.DBF", STRU_TMP )
   use ("TEMP.DBF") alias tmp exclusive new
   if neterr()
      return .F.
   endif
   for nA := 1 to len( aInv )
      tmp->(dbAppend())
      tmp->numms   := TiraPonto( aInv[ nA, 1 ] )
      tmp->nomepro := aInv[ nA, 2 ]
      tmp->numlote := aInv[ nA, 3 ]
      tmp->qtdlote := val( aInv[ nA, 4 ] )
   next
   tmp->(dbCloseArea())
RETURN .T.

*******************************
STATIC FUNCTION TIRAPONTO( ms )
*******************************
   local nA, nLen := len( alltrim( ms ) ), cRet := ""

   for nA := 1 to nLen
      if isdigit( substr( ms, nA, 1 ) )
         cRet += substr( ms, nA, 1 )
      endif
   next
RETURN cRet

*********************
FUNCTION InternetOK()
*********************
   local aHosts, cName, cAddress := "www.google.com.br"
   InetInit()
   aHosts := InetGetHosts( cAddress )
   if aHosts == NIL .or. len(aHosts) == 0
      InetCleanup()
      return .F.
   endif
   InetCleanup()
RETURN .T.

 

Link to comment
Share on other sites

Olá,

Depois de muito tempo gerando o XML e usando o próprio site do SNGPC para enviar meus arquivos, decidi que já era hora de enviar esses arquivos do meu sistema.

Criei os tres serviços oficiais do SNGPC ( validar usuário, enviar arquivo XML e testar arquivo enviado ) mais a importação do inventário direto da ANVISA.

Essa primeira rotina, valida um email/senha para ver se esta cadastrado no SNGPC da ANVISA. No código estão os endereços de homologação e produção.


//
// WebService com xHarbour
//
// Nesse exemplo estamos testando se o email/senha do usuario
// esta cadastrado no SNGPC da ANVISA.
//
// Existem ainda mais 2 servicos :
//
// a) enviar arquivo XML.
// b) verificar se arquivo XML enviado foi validado.
//
// Manoel Angeiras
//

#define CR_LF chr(13) + chr(10)

***************
FUNCTION MAIN()
***************
 if !InternetOK()
   Alert("Conexao com a internet falhou !")
 else
   Alert("Conexao OK")
 endif
 //
 // Abertura das funcoes para WebService do xHarbour
 //
 try
   doc := CreateObject( "MSXML2.DOMDocument" )
 catch
   try
    doc := CreateObject( "MSXML2.DOMDocument" )
   catch
    Alert("Erro na criacao do objeto MSXML2.DOMDocument : " + Ole2TxtError())
    return NIL
   end
 end

 try
   http := CreateObject( "MSXML2.XMLHTTP" )
 catch
   try
    http := CreateObject( "MSXML2.XMLHTTP" )
   catch
    Alert("Erro na criacao do objeto MSXML2.XMLHTTP : " + Ole2TxtError())
   end
 end
 //
 // Criar o XML request
 //
 cXml := ""
 cXml += '<?xml version="1.0" encoding="utf-8"?>' + CR_LF
 cXml += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">' + CR_LF
 cXml += ' <soapenv:Header/>' + CR_LF
 cXml += ' <soapenv:Body>' + CR_LF
 cXml += '  <tem:ValidarUsuario>' + CR_LF
 cXml += '   <tem:Email>seu_email_aqui</tem:Email>' + CR_LF // SEU EMAIL AQUI
 cXml += '   <tem:Senha>sua_senha_aqui</tem:Senha>' + CR_LF     // SUA SENHA AQUI
 cXml += '  </tem:ValidarUsuario>' + CR_LF
 cXml += ' </soapenv:Body> ' + CR_LF
 cXml += '</soapenv:Envelope>' + CR_LF

//
// ENDERECO DE HOMOLOGACAO
// 
 http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
 http:SetRequestHeader( "Content-Type" , "text/xml;charset=UTF-8" )
 http:SetRequestHeader( "SOAPAction"  , "http://tempuri.org/ValidarUsuario" )
 http:SetRequestHeader( "Host"     , "homologacao.anvisa.gov.br" )

//
// ENDERECO DE PRODUCAO
// 
// http:Open( "POST", "http://sngpc.anvisa.gov.br/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
// http:SetRequestHeader( "Content-Type" , "text/xml;charset=UTF-8" )
// http:SetRequestHeader( "SOAPAction"  , "http://tempuri.org/ConsultaDadosArquivoSNGPC" )
// http:SetRequestHeader( "Host"     , "sngpc.anvisa.gov.br" )

 Alert("Carrega o request...")
 doc:LoadXML( cXml )        // Carrega o request de string

 Alert("Envia o xml...")
 http:send( doc:xml )       // Envia o request

 Alert("Ler a resposta...")
 response := http:responseText  // Recebe a resposta

 Alert("Apresentando a resposta")

 oXmlDoc := TXmlDocument():new()
 oXMlDoc:read( response )

 oXmlNode := oXmlDoc:findFirst( "ValidarUsuarioResult" )
 Alert(oXmlNode:cName + " = " + oXmlNode:cData )

RETURN NIL

*********************
FUNCTION InternetOK()
*********************
 local aHosts, cName, cAddress := "www.google.com.br"
 InetInit()
 aHosts := InetGetHosts( cAddress )
 if aHosts == NIL .or. len(aHosts) == 0
   InetCleanup()
   return .F.
 endif
 InetCleanup()
RETURN .T.

 

Link to comment
Share on other sites

aos que precisarem, segue o restante :

 

 

Exemplo - Enviando arquivo XML

Nesse segundo exemplo, vamos enviar o arquivo XML para ANVISA. Note que no XML as tags < e > devem ser trocadas por & l t ; e & g t ;.
Claro que esse hash calculado deve ser gravado em algum lugar para depois testar se o arquivo foi recebido, se está com erros, etc. Vamos ver o uso desse código no próximo exemplo.


 

 

 

 

#define CR_LF chr(13) + chr(10)

 

***************

FUNCTION MAIN()

***************

   if !InternetOK()

      Alert("Sem conexão com a Internet. Verifique...")

      return .F.

   endif

   //

   // ABERTURA DAS FUNCOES PARA WEBSERVICE DO XHARBOUR - OBJETO HTTP

   //

   try

      http := CreateObject( "MSXML2.XMLHTTP" )

   catch

      try

         http := CreateObject( "MSXML2.XMLHTTP" )

      catch

         Alert("Erro na criação do objeto MSXML2.XMLHTTP : " + Ole2TxtError())

      end

   end

   //

   // CRIA OBJETO XML

   //

   try

      doc := CreateObject( "MSXML2.DOMDocument" )

   catch

      try

         doc := CreateObject( "MSXML2.DOMDocument" )

      catch

         Alert("Erro na criacao do objeto MSXML2.DOMDocument : " + Ole2TxtError())

         return NIL

      end

   end

 

   cFile := memoread( seu_arquivo_xml )

   cHash := HB_MD5File( seu_arquivo_xml )

 

   cXml := ""

   cXml += '<?xml version="1.0" encoding="ISO-8859-1" ?>' + CR_LF

   cXml += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">' + CR_LF

   cXml += '  <soapenv:Header/>' + CR_LF

   cXml += '  <soapenv:Body>' + CR_LF

   cXml += '    <tem:EnviaArquivoSNGPC>' + CR_LF

   cXml += '      <tem:Email>' + SEU_EMAIL_AQUI + '</tem:Email>' + CR_LF

   cXml += '      <tem:Senha>' + SUA_SENHA_AQUI + '</tem:Senha>' + CR_LF

   cXml += '      <tem:Arquivo>' + cFile + '</tem:Arquivo>' + CR_LF

   cXml += '      <tem:HashIdentificacao>' + cHash + '</tem:HashIdentificacao>' + CR_LF

   cXml += '    </tem:EnviaArquivoSNGPC>' + CR_LF

   cXml += '  </soapenv:Body> ' + CR_LF

   cXml += '</soapenv:Envelope>' + CR_LF

 

//

// ENDERECO HOMOLOGACAO

//

   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )

   http:SetRequestHeader( "Content-Type"   , "text/xml;charset=ISO-8859-1" )

   http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/EnviaArquivoSNGPC" )

   http:SetRequestHeader( "Host"           , "homologacao.anvisa.gov.br" )

 

//

// ENDERECO PRODUCAO

//

// http:Open( "POST", "http://sngpc.anvisa.gov.br/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )

// http:SetRequestHeader( "Content-Type"   , "text/xml;charset=ISO-8859-1" )

// http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/EnviaArquivoSNGPC" )

// http:SetRequestHeader( "Host"           , "sngpc.anvisa.gov.br" )

 

   doc:LoadXML( cXml )

   http:send( doc:xml )

   response  := http:responseText

   oXmlDoc   := TXmlDocument():new()

   oXMlDoc:read( response )

 

   oXmlNode := oXmlDoc:findFirst( "EnviaArquivoSNGPCResult" )

   if empty( oXmlNode:cData )

      Alert("Erro no envio do arquivo para ANVISA. Tente outra vez.")

   elseif upper( left( oXmlNode:cData, 28 ) ) == "ARQUIVO RECEBIDO COM SUCESSO"

      Alert(oXmlNode:cData)

   else

      Alert(oXmlNode:cData)

      Alert("Erro no envio do arquivo para ANVISA. Tente outra vez.")

   endif

RETURN NIL

 

*********************

FUNCTION InternetOK()

*********************

   local aHosts, cName, cAddress := "www.google.com.br"

   InetInit()

   aHosts := InetGetHosts( cAddress )

   if aHosts == NIL .or. len(aHosts) == 0

      InetCleanup()

      return .F.

   endif

   InetCleanup()

RETURN .T.

Link to comment
Share on other sites

Exemplo - Testando status do arquivo XML enviado
Nesse terceiro exemplo, testamos o recebimento do arquivo XML ou podemos obter a relação de erros de validação e gerar um relatório de erros. A parte do exemplo que trata dos erros deve ser melhor estudada e/ou melhorada.


#define CR_LF chr(13) + chr(10)

***************
FUNCTION MAIN()
***************
   local lRet := .T.

   if !InternetOK()
      Alert("Sem conexão com a Internet. Verifique...")
      return .F.
   endif
   //
   // ABERTURA DAS FUNCOES PARA WEBSERVICE DO XHARBOUR - OBJETO HTTP
   //
   try
      http := CreateObject( "MSXML2.XMLHTTP" )
   catch
      try
         http := CreateObject( "MSXML2.XMLHTTP" )
      catch
         Alert("Erro na criação do objeto MSXML2.XMLHTTP : " + Ole2TxtError())
      end
   end
   //
   // CRIA OBJETO XML
   //
   try
      doc := CreateObject( "MSXML2.DOMDocument" )
   catch
      try
         doc := CreateObject( "MSXML2.DOMDocument" )
      catch
         Alert("Erro na criacao do objeto MSXML2.DOMDocument : " + Ole2TxtError())
         return .F.
      end
   end

   cXml := ""
   cXml += '<?xml version="1.0" encoding="ISO-8859-1" ?>' + CR_LF
   cXml += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">' + CR_LF
   cXml += '  <soapenv:Header/>' + CR_LF
   cXml += '  <soapenv:Body>' + CR_LF
   cXml += '    <tem:ConsultaDadosArquivoSNGPC>' + CR_LF
   cXml += '      <tem:Email>' + SEU_EMAIL_AQUI + '</tem:Email>' + CR_LF
   cXml += '      <tem:Senha>' + SUA_SENHA_AQUI + '</tem:Senha>' + CR_LF
   cXml += '      <tem:CNPJ>' + CNPJ_DA_EMPRESA + '</tem:CNPJ>' + CR_LF
   cXml += '      <tem:Hash>' + HASH_DO_ARQUIVO + '</tem:Hash>' + CR_LF
   cXml += '    </tem:ConsultaDadosArquivoSNGPC>' + CR_LF
   cXml += '  </soapenv:Body> ' + CR_LF
   cXml += '</soapenv:Envelope>' + CR_LF

//
// ENDERECO HOMOLOGACAO
//
   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
   http:SetRequestHeader( "Content-Type"   , "text/xml;charset=ISO-8859-1" )
   http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/ConsultaDadosArquivoSNGPC" )
   http:SetRequestHeader( "Host"           , "homologacao.anvisa.gov.br" )

//
// ENDERECO PRODUCAO
//
// http:Open( "POST", "http://sngpc.anvisa.gov.br/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
// http:SetRequestHeader( "Content-Type"   , "text/xml;charset=ISO-8859-1" )
// http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/ConsultaDadosArquivoSNGPC" )
// http:SetRequestHeader( "Host"           , "sngpc.anvisa.gov.br" )

   doc:LoadXML( cXml )
   http:send( doc:xml )
   response  := http:responseText
   oXmlDoc   := TXmlDocument():new()
   oXMlDoc:read( response )

   oXmlNode := oXmlDoc:findFirst( "ConsultaDadosArquivoSNGPCResult" )
   cDados   := oXmlNode:cData

   oXMlDoc:read( cDados )

   oXmlNode := oXmlDoc:findFirst( "DATAVALIDACAO" )

   if oXmlNode == NIL .or. oXmlNode:cData == NIL .or. empty( oXmlNode:cData )
      Alert("Arquivo ainda nao foi validado...")
      lRet := .F.
   else
      cMens    := oXmlNode:cData
      oXmlNode := oXmlDoc:findFirst( "MENSAGEMVALIDACAO" )
      if oXmlNode == NIL
         Alert("Arquivo validado em : " + cMens )
      else
         nHandle := fcreate( "temp.txt" )
         fwrite( nHandle, oXmlNode:cData )
         fclose( nHandle )
         nHandle := fopen( "temp.txt" )
         aLinhas := {}
         cLinha  := ""

         while HB_FReadLine( nHandle, @cLinha, "[NOVA_LINHA]" ) == 0
            aadd( aLinhas, cLinha )
         enddo
         aadd( aLinhas, cLinha )
         fclose( nHandle )

         if Alert("Arquivo enviado n„o foi recebido. Emite relat¢rio com erros ?", { "SIM", "NAO" } ) == 1
            // IMPRIME RELATORIO COM ERROS DE VALIDACAO DO XML
         endif
         lRet := .F.
      endif
   endif
RETURN lRet

*********************
FUNCTION InternetOK()
*********************
   local aHosts, cName, cAddress := "www.google.com.br"
   InetInit()
   aHosts := InetGetHosts( cAddress )
   if aHosts == NIL .or. len(aHosts) == 0
      InetCleanup()
      return .F.
   endif
   InetCleanup()
RETURN .T.

 

Link to comment
Share on other sites

e finalmente o ultimo exemplo:

 

Exemplo - Validando Usuário
Estou usando o seguinte código para validar o usuário/senha :






#define CR_LF chr(13) + chr(10)

***************
FUNCTION MAIN()
***************
   if !InternetOK()
      Alert("Conexao com a internet falhou !")
   else
      Alert("Conexao OK")
   endif
   //
   // Abertura das funcoes para WebService do xHarbour
   //
   try
      doc := CreateObject( "MSXML2.DOMDocument" )
   catch
      try
         doc := CreateObject( "MSXML2.DOMDocument" )
      catch
         Alert("Erro na criacao do objeto MSXML2.DOMDocument : " + Ole2TxtError())
         return NIL
      end
   end

   try
      http := CreateObject( "MSXML2.XMLHTTP" )
   catch
      try
         http := CreateObject( "MSXML2.XMLHTTP" )
      catch
         Alert("Erro na criacao do objeto MSXML2.XMLHTTP : " + Ole2TxtError())
      end
   end
   //
   // Criar o XML request
   //
   cXml := ""
   cXml += '<?xml version="1.0" encoding="utf-8"?>' + CR_LF
   cXml += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">' + CR_LF
   cXml += '  <soapenv:Header/>' + CR_LF
   cXml += '  <soapenv:Body>' + CR_LF
   cXml += '    <tem:ValidarUsuario>' + CR_LF
   cXml += '      <tem:Email>SEU_EMAIL_AQUI</tem:Email>' + CR_LF
   cXml += '      <tem:Senha>SUA_SENHA_AQUI</tem:Senha>' + CR_LF
   cXml += '    </tem:ValidarUsuario>' + CR_LF
   cXml += '  </soapenv:Body> ' + CR_LF
   cXml += '</soapenv:Envelope>' + CR_LF

//
// ENDERECO DE HOMOLOGACAO
//   
   http:Open( "POST", "http://homologacao.anvisa.gov.br/sngpc/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
   http:SetRequestHeader( "Content-Type"   , "text/xml;charset=UTF-8" )
   http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/ValidarUsuario" )
   http:SetRequestHeader( "Host"           , "homologacao.anvisa.gov.br" )

//
// ENDERECO DE PRODUCAO
//   
// http:Open( "POST", "http://sngpc.anvisa.gov.br/webservice/sngpc.asmx?WSDL HTTP/1.1", .F. )
// http:SetRequestHeader( "Content-Type"   , "text/xml;charset=UTF-8" )
// http:SetRequestHeader( "SOAPAction"     , "http://tempuri.org/ValidarUsuario" )
// http:SetRequestHeader( "Host"           , "sngpc.anvisa.gov.br" )

   Alert("Carrega o request...")
   doc:LoadXML( cXml )                // Carrega o request de string

   Alert("Envia o xml...")
   http:send( doc:xml )               // Envia o request

   Alert("Ler a resposta...")
   response  := http:responseText     // Recebe a resposta

   Alert("Apresentando a resposta")

   oXmlDoc := TXmlDocument():new()
   oXMlDoc:read( response )

   oXmlNode := oXmlDoc:findFirst( "ValidarUsuarioResult" )
   Alert(oXmlNode:cName + " = " + oXmlNode:cData )

RETURN NIL

*********************
FUNCTION InternetOK()
*********************
   local aHosts, cName, cAddress := "www.google.com.br"
   InetInit()
   aHosts := InetGetHosts( cAddress )
   if aHosts == NIL .or. len(aHosts) == 0
      InetCleanup()
      return .F.
   endif
   InetCleanup()
RETURN .T.

 

Link to comment
Share on other sites

Algumas dúvidas:

1 - De que se trata o inventário? Seria o estoque da farmácia no banco de dados do SNGPC?

2 - Os medicamentos e insumos movimentados (enviados) são incluídos e baixados do inventário?

3 - Quais as limitações ou requisitos para envio de inventários?

Link to comment
Share on other sites

vamos lá:

 

1 - De que se trata o inventário? Seria o estoque da farmácia no banco de dados do SNGPC?

R- Sim é o cadastro de produtos controlados contendo quantidade, codigo de barras , numero do lote , numero da Anvisa do medicamento, etc...

 

2 - Os medicamentos e insumos movimentados (enviados) são incluídos e baixados do inventário?

R- Sim devem ser incluidos as quantidades e numeros de lote de tudo que é comprado. E tudo que se vende tambem deve ser baixado. Sendo assim , na Anvisa fica uma cópia do estoque da farmacia. Os envios diarios dos xmls que atualizam o estoque na Anvisa. Diariamente é transmitido um xml com o resumo de tudo que entrou e saiu dos medic e insumos controlados,

 

3 - Quais as limitações ou requisitos para envio de inventários?

R- Nao me lembro bem, mas acredito que o inventario deva ser entregue no inicio das operacoes da farmacia. Ou com a troca do responsavel , ou para acerto de estoque. Tem diversos motivos pra isso. No site  do SNGPC tem um item "Finalizar Inventario" e lá mostra a lista de motivos existentes.

 

Att.

 

William

 

 

 

Link to comment
Share on other sites

Mestres,

Estou fazendo testes de comunicação com os WebServices do SNGPC e só o ambiente de produção responde. Alguém sabe me informar se o ambiente de homologação está desativado ou mudou de endereço?

Produção responde: 

http://sngpc.anvisa.gov.br/webservice/sngpc.asmx?WSDL HTTP/1.1

Homologação não responde:

http://homologacao.anvisa.gov.br/sngpc/webservice/sngpc.asmx?WSDL HTTP/1.1

 

Link to comment
Share on other sites

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...