select
v_PersonState.Person_SurName, v_PersonState.Person_FirName, v_PersonState.Person_SecName, v_PersonState.Person_BirthDay, 
trim(COALESCE((v_PersonState.Polis_Ser || ' ')  , '') || COALESCE(Polis_Num, ''))  as Polis,
v_Lpu.Lpu_Name, LpuSection.LpuSection_Name, EvnPS_NumCard, evn.Evn_setDT, evn.Evn_disDT, LeaveType.LeaveType_Name, Diag_Code || ' - ' || diag.Diag_Name  as diag
from dbo.EvnPS
left join dbo.LeaveType on LeaveType.LeaveType_id = EvnPS.LeaveType_id
join evn on EvnPS.Evn_id = evn.Evn_id
join Diag on EvnPS.Diag_id = Diag.Diag_id
join PersonEvn on evn.PersonEvn_id = PersonEvn.PersonEvn_id
join v_PersonState on v_PersonState.Person_id = PersonEvn.Person_id
join v_Lpu on evn.Lpu_id = v_Lpu.Lpu_id and coalesce(Lpu_IsTest, 1) = 1    
and Lpu_begDate <= dbo.tzGetDate() + interval '1 year'   
and (Lpu_endDate >= to_timestamp('01.01.2020', 'dd.mm.YYYY') or Lpu_endDate is null)
join LpuSection on EvnPS.LpuSection_id = LpuSection.LpuSection_id
where trim(COALESCE((v_PersonState.Polis_Ser || ' ')  , '') || COALESCE(dbo.v_personstate.polis_num, '')) = '5054010873000601'
and trim(COALESCE((v_PersonState.Polis_Ser || ' ')  , '') || COALESCE(dbo.v_personstate.polis_num, '')) != ''
and dbo.EvnPS.Evn_deleted = 1
