<?php
if(!@$rc) {
    $rc = 0;
}
?>
<div class="conditions-tree" id="remote-monitoring-tree">
    <div class="condition">
        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=2"
                {!! $rc == 2 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many are enrolled in RPM?
            <span class="rm-count ml-1" data-rc="2">(0)</span>
        </a>
        <div class="condition-children">
            <div class="condition">
                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=3"
                        {!! $rc == 3 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many given a cellular device?
                    <span class="rm-count ml-1" data-rc="3">(0)</span>
                </a>
                <div class="condition-children">
                    <div class="condition">
                        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=4"
                                {!! $rc == 4 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many seen w/in 90 days?
                            <span class="rm-count ml-1" data-rc="4">(0)</span>
                        </a>
                        <div class="condition-children">
                            <div class="condition">
                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=5"
                                        {!! $rc == 5 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many spoken to this month?
                                    <span class="rm-count ml-1" data-rc="5">(0)</span>
                                </a>
                                <div class="condition-children">
                                    <div class="condition">
                                        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=6"
                                                {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with no unstamped meas.?
                                            <span class="rm-count ml-1" data-rc="6">(0)</span>
                                        </a>
                                    </div>
                                    <div class="condition">
                                        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=7"
                                                {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 16 or more meas. days?
                                            <span class="rm-count ml-1" data-rc="7">(0)</span>
                                        </a>
                                        <div class="condition-children">
                                            <div class="condition">
                                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=10"
                                                        {!! $rc == 10 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 20 or more billing mins.?
                                                    <span class="rm-count ml-1" data-rc="10">(0)</span>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="condition">
                        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=8"
                                {!! $rc == 8 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have subscribed to SMS?
                            <span class="rm-count ml-1" data-rc="8">(0)</span>
                        </a>
                    </div>
                    <div class="condition">
                        <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=9"
                                {!! $rc == 9 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have used the device?
                            <span class="rm-count ml-1" data-rc="9">(0)</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    (function() {
        function init() {
            window.setTimeout(() => {
                $('#remote-monitoring-tree .rm-count').each(function() {
                    let params = '?rc=' + $(this).attr('data-rc');
                    if($(this).is('[data-rc2]')) params += '&rc2=' + $(this).attr('data-rc2');
                    @if(request()->input('m')) params += '&m={{request()->input('m')}}'; @endif
                    @if(request()->input('y')) params += '&y={{request()->input('y')}}'; @endif
                    $.get('{{route('practice-management.remote-monitoring-admin-count')}}' + params, _data => {
                        $(this).text('(' + _data + ')');
                    });
                });
            }, 250);
        }
        addMCInitializer('remote-monitoring-tree', init, '#remote-monitoring-tree')
    }).call(window);
</script>
