Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. 708 medicalCard.service.for.organization Вид услуги select id,
  2. case
  3. when is_complex is true then concat('[+]', coalesce(code, ''), ' ', name)
  4. else concat(coalesce(code, ''), ' ', name)
  5. end,
  6. duration_unit_id,
  7. case
  8. when is_complex is true then cul = get_service_cul(id, is_complex)
  9. else is_actual_cul
  10. end as is_actual_cul,
  11. case
  12. when is_complex is true then get_service_cul(id, is_complex)
  13. else cul
  14. end as cul,
  15. is_multuplicity,
  16. prototype_id,
  17. is_fictitious,
  18. is_stomat,
  19. is_filling,
  20. is_need_anatomic_zone,
  21. is_need_close_date
  22. from sr_service SUGGESTION where id = :id where org_id = :orgId and (is_fictitious is not true)
  23. and lower('[+]'||coalesce(code, '')||' '||name) like '%'||lower(:text)||'%'
  24. and (from_dt is null or from_dt<=to_date(:date, 'DD.MM.YYYY')) and
  25. (to_dt is null or to_dt>=to_date(:date, 'DD.MM.YYYY'))
  26. and(:resGroupId::integer is null
  27. or (exists (select 1 from sr_res_group_service gs join sr_res_group rg on rg.template_res_group_id = gs.group_id
  28. where srv_type_id = sr_service.id and rg.id = :resGroupId)
  29. and exists(select 1 from sr_res_group_service gs join sr_res_group rg on rg.template_res_group_id = gs.group_id
  30. where rg.id = :resGroupId)
  31. )
  32. or (exists (select 1 from sr_res_group_service where srv_type_id = sr_service.id and group_id = :resGroupId)
  33. and exists(select 1 from sr_res_group_service where group_id = :resGroupId)
  34. )
  35. or (not exists(select 1 from sr_res_group_service where group_id = :resGroupId)
  36. and not exists(select 1 from sr_res_group_service gs join sr_res_group rg on rg.template_res_group_id = gs.group_id
  37. where rg.id = :resGroupId))
  38. ) app_group_master 2016-12-20 21:51:11.184643 DB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement