Advertisement
Guest User

Untitled

a guest
Oct 11th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION      hbs_obter_valor_atendimento(    nr_atendimento_p  NUMBER)
  2.                     RETURN NUMBER IS
  3. -- 09-10-2019 - função criada para indentificar a receita de um atendimento. Gabriela Colonetti
  4.  
  5. vl_procedimento_w NUMBER (15,2);
  6. vl_material_w NUMBER (15,2);
  7. vl_resultado_w NUMBER (15,2);
  8.  
  9. BEGIN
  10.  
  11. SELECT SUM (a.vl_procedimento)
  12. INTO vl_procedimento_w
  13. FROM tasy.procedimento_paciente a join conta_paciente b ON a.nr_interno_conta = b.nr_interno_conta
  14. WHERE a.nr_atendimento = nr_atendimento_p
  15. AND a.cd_motivo_exc_conta IS NULL
  16. AND ((a.nr_seq_proc_pacote <> a.nr_sequencia) OR (a.nr_seq_proc_pacote IS NULL))AND b.ie_cancelamento IS NULL;
  17.  
  18. SELECT SUM (a.vl_material)
  19. INTO vl_material_w
  20. FROM tasy.material_atend_paciente a join conta_paciente  b ON a.nr_interno_conta = b.nr_interno_conta
  21. WHERE a.nr_atendimento = nr_atendimento_p
  22. AND a.cd_motivo_exc_conta IS NULL;
  23.  
  24.  
  25.  
  26.             vl_resultado_w := vl_procedimento_w + vl_material_w;
  27.  
  28.  
  29. RETURN NVL(vl_resultado_w,0);
  30.  
  31. END hbs_obter_valor_atendimento;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement