
            select DISTINCT
                UT.EvnLabSample_id as "EvnLabSample_id"
            from v_EvnLabSample ELS
                inner join v_EvnLabRequest ELR on ELR.EvnLabRequest_id = ELS.EvnLabRequest_id
                inner join v_UslugaTest UT on UT.EvnLabSample_id = ELS.EvnLabSample_id
                left join v_EvnUslugaPar eupp on eupp.EvnUslugaPar_id = ut.UslugaTest_pid
                left join v_UslugaComplex uc ON ut.UslugaComplex_id = uc.UslugaComplex_id
                left join v_UslugaComplex ucp ON eupp.UslugaComplex_id = ucp.UslugaComplex_id
                left join v_UslugaComplexMedService ucms on ucms.UslugaComplex_id = uc.UslugaComplex_id
                inner join lis.v_AnalyzerTest AnT on AnT.UslugaComplexMedService_id = ucms.UslugaComplexMedService_id
                inner join lis.v_Analyzer A on A.Analyzer_id = AnT.Analyzer_id and A.MedService_id = ELR.MedService_id
                inner join v_MethodsIFAAnalyzerTest MIAT on MIAT.AnalyzerTest_id = AnT.AnalyzerTest_id
                inner join v_MethodsIFA MI on MI.MethodsIFA_id = MIAT.MethodsIFA_id
            where els.EvnLabSample_setDT is not null and ELS.MedService_id = '15851' and '2023-07-12' <= COALESCE(
            cast(els.EvnLabSample_StudyDT as date),
            cast(els.EvnLabSample_setDate as date),
            cast(elr.EvnLabRequest_didDate as date)
        ) and '2023-07-25' >= COALESCE(
            cast(els.EvnLabSample_StudyDT as date),
            cast(els.EvnLabSample_setDate as date),
            cast(elr.EvnLabRequest_didDate as date)
        )
        
