
                                select
                                    EU.EvnUsluga_id as "EvnUsluga_id",
                                    to_char(EU.EvnUsluga_setDT, 'dd.mm.yyyy') as "EvnUsluga_setDate",
                                    UC.UslugaComplex_id as "UslugaComplex_id",
                                    UC.UslugaComplex_Code as "UslugaComplex_Code",
                                    UC.UslugaComplex_Name as "UslugaComplex_Name",
                                    EU.EvnClass_SysNick as "EvnClass_SysNick",
                                    EP.EvnCourse_id as "EvnCourse_id"
                                from dbo.v_EvnUsluga EU
                                    inner join dbo.v_UslugaComplex UC
                                        on UC.UslugaComplex_id = EU.UslugaComplex_id
                                    left join dbo.v_EvnPrescr EP
                                        on EP.EvnPrescr_id = EU.EvnPrescr_id
                                    left join dbo.v_PrescriptionType PT
                                        on EP.PrescriptionType_id = PT.PrescriptionType_id
                                where (EU.EvnUsluga_pid = '910101106674908' or EP.EvnPrescr_pid = '910101106674908')
                                    and 1 = (case when PT.PrescriptionType_Code in (7, 13)
                                        and EU.EvnClass_SysNick = 'EvnUslugaPar' then 0 else 1 end)
                                    and 1 = 1
                                order by EU.EvnUsluga_setDT
                            
