
            select
                RootEvn.EvnClass_id as "RootEvnClass_id",
                RootEvn.EvnClass_SysNick as "RootEvnClass_SysNick",
                RootEvn.EvnClass_Name as "RootEvnClass_Name",
                ParentEvn.EvnClass_id as "ParentEvnClass_id",
                ParentEvn.EvnClass_SysNick as "ParentEvnClass_SysNick",
                ParentEvn.EvnClass_Name as "ParentEvnClass_Name",
                eu.EvnUsluga_rid as "EvnUsluga_rid",
                eu.EvnUsluga_pid as "EvnUsluga_pid",
                eu.EvnClass_id as "EvnClass_id",
                eu.EvnClass_SysNick as "EvnClass_SysNick",
                eu.EvnClass_Name as "EvnClass_Name",
                eu.PersonEvn_id as "PersonEvn_id",
                uc.UslugaComplex_Code as "UslugaComplex_Code",
                uc.UslugaComplex_Name as "UslugaComplex_Name",
                msf.Person_SurName as "Person_SurName",
                msf.Person_FirName as "Person_FirName",
                msf.Person_SecName as "Person_SecName",
             	p.Post_id as "Post_id",
                p.Post_Name as "Post_Name",
                case
                    when msf.LpuSection_id is not null then msf.LpuSection_id
                    else msf.Lpu_id
                end as "LpuStruct_id",
                case
                    when msf.LpuSection_id is not null then 'LpuSection'
                    else 'Lpu'
                end as "SysNick",
             	case
                    when msf.LpuSection_id is not null then ls.LpuSection_Name
                    else l.Lpu_Nick
                end as "Value"
            from v_EvnUsluga eu
                inner join v_Evn as RootEvn on RootEvn.Evn_id = eu.EvnUsluga_rid
                inner join v_Evn as ParentEvn on ParentEvn.Evn_id = eu.EvnUsluga_pid
                inner join v_MedStaffFact msf on msf.MedStaffFact_id = eu.MedStaffFact_id
                inner join v_UslugaComplex uc on uc.UslugaComplex_id = eu.UslugaComplex_id
                left join v_Post p on p.Post_id = msf.Post_id
                left join v_LpuSection ls on ls.LpuSection_id = msf.LpuSection_id
                left join v_Lpu l on l.Lpu_id = msf.Lpu_id
            where eu.EvnUsluga_id = '890101023489505'
            limit 1
        
