SELECT
BE2_ANOAUT AS AnoAutorizacao,
BE2_AUDITO AS Auditoria,
BE2_CODESP AS CodigoEspecialidade,
BE2_CODLOC AS CodigoLocalAtendimento,
BE2_CODPRO AS CodigoProcedimento,
BE2_CODRDA AS CodigoRedeAtendimento,
BE2_CODPAD AS CodigoTabela,
BE2_DATPRO AS Data,
BE2_HORPRO AS Hora,
BE2_LOCAL AS LocalAtendimento,
BE2_MESAUT AS MesAutorizacao,
BE2_NUMAUT AS NumeroAutorizacao,
BE2_OPEMOV AS OperadoraMovimentacao,
BE2_OPERDA AS OperadoraRedeAtendimento,
BE2_SALDO AS SaldoProcedimento,
BE2_SEQUEN AS SequencialProcedimento,
BE2_STATUS AS Status,
BE2_TIPO AS TipoProcedimento
FROM BE2010 BE2
INNER JOIN BEA010 BEA
ON (
BEA_OPEMOV = BE2_OPEMOV
AND BEA_ANOAUT = BE2_ANOAUT
AND BEA_MESAUT = BE2_MESAUT
AND BEA_NUMAUT = BE2_NUMAUT
)
WHERE
BE2_OPEMOV = '0001'
AND BE2_LIBERA = '1'
AND BE2_TIPO != '3'
AND BEA_ORIMOV != '6'
AND BE2.D_E_L_E_T_ = ' '
AND BEA.D_E_L_E_T_ = ' '
AND BE2.S_T_A_M_P_ > (DATEADD(HOUR, -1, GETUTCDATE())) |