
                    select
                        count(*) as "cnt"
                    from v_TimetableGraf_lite
                    where
                        MedStaffFact_id = '180101000143874'
                        and ((TimetableGraf_begTime >= '2023-07-29 08:00:00' and TimetableGraf_begTime < '2023-07-29 18:00:00')
                            or ((TimetableGraf_begTime::timestamp +
                                    CAST(TimetableGraf_Time||' minutes' as interval)) > '2023-07-29 08:00:00'
                                and (TimetableGraf_begTime::timestamp +
                                        CAST(TimetableGraf_Time||' minutes' as interval)) < '2023-07-29 18:00:00')
                            or ((TimetableGraf_begTime::timestamp +
                                    CAST(TimetableGraf_Time||' minutes' as interval)) > '2023-07-29 08:00:00'
                                and TimetableGraf_begTime < '2023-07-29 08:00:00')
                            )
