SELECT
BEJ_ANOINT AS AnoAutorizacao,
BEJ_AUDITO AS Auditoria,
BE2_CODESP AS CodigoEspecialidade,
BE2_CODLOC AS CodigoLocalAtendimento,
BEJ_CODPRO AS CodigoProcedimento,
BE2_CODRDA AS CodigoRedeAtendimento,
BEJ_CODPAD AS CodigoTabela,
BEJ_DATPRO AS Data,
BE2_HORPRO AS Hora,
BE2_LOCAL AS LocalAtendimento,
BEJ_MESINT AS MesAutorizacao,
BEJ_NUMINT AS NumeroAutorizacao,
BEJ_CODOPE AS OperadoraMovimentacao,
BE2_OPERDA AS OperadoraRedeAtendimento,
BE2_SALDO AS SaldoProcedimento,
BEJ_SEQUEN AS SequencialProcedimento,
BEJ_STATUS AS Status,
BE2_TIPO AS TipoProcedimento
FROM BEJ010 BEJ
INNER JOIN BE4010 BE4
ON (
BE4_CODOPE = BEJ_CODOPE
AND BE4_ANOINT = BEJ_ANOINT
AND BE4_MESINT = BEJ_MESINT
AND BE4_NUMINT = BEJ_NUMINT
)
INNER JOIN BE2010 BE2
ON (
BE2_OPEMOV = BEJ_CODOPE
AND BE2_ANOINT = BEJ_ANOINT
AND BE2_MESINT = BEJ_MESINT
AND BE2_NUMINT = BEJ_NUMINT
)
WHERE
BEJ_CODOPE = '0001'
AND BE4_TIPGUI = '03'
AND BE4_ORIMOV != '6'
AND BEJ.D_E_L_E_T_ = ' '
AND BE4.D_E_L_E_T_ = ' '
AND BE2.D_E_L_E_T_ = ' '
AND BEJ.S_T_A_M_P_ > (DATEADD(HOUR, -1, GETUTCDATE())) |