
            select
                ES.EvnStick_id as "EvnStick_id",
                ES.Org_id as "Org_id",
                rtrim(coalesce(ES.EvnStick_Ser, '')) as "EvnStick_Ser",
                rtrim(coalesce(ES.EvnStick_Num, '')) as "EvnStick_Num",
                to_char(ES.EvnStick_setDate, 'dd.mm.yyyy') as "EvnStick_setDate",
                to_char(ES.EvnStick_disDate, 'dd.mm.yyyy') as "EvnStick_disDate",
                rtrim(coalesce(SO.StickOrder_Name, '')) as "StickOrder_Name",
                (
                    coalesce(ES.EvnStick_Ser, '')||' '||coalesce(ES.EvnStick_Num, '')||
                    (case when (ES.EvnStick_setDate IS NOT NULL) then ' выдан: '||to_char(ES.EvnStick_setDate, 'dd.mm.yyyy') else '' end) ||
                    (case when (ES.EvnStick_disDate IS NOT NULL) then ' по '||to_char(ES.EvnStick_disDate, 'dd.mm.yyyy') else '' end)
                ) as "EvnStick_all"
            from
                v_EvnStick ES
                left join v_StickOrder SO on SO.StickOrder_id = ES.StickOrder_id
            where
                (1=1) and (
                ES.Person_id = '8064902'
                or '8064902' in (select Person_id from v_EvnStickCarePerson where Evn_id = ES.EvnStick_id)
            )
        
