@extends ('layouts/template')

@section('content')
<div class="p-3 mcp-theme-1">
    <div class="card">
        <div class="card-header px-2 py-1 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-chart-bar"></i>
                Remote Monitoring Report
                <span class="inline-block mr-2">|</span>
                <a href="/practice-management/remote-monitoring-report">Show All</a>
                <span class="inline-block mr-2">|</span>
                <a href="/practice-management/remote-monitoring-report?show_billing_not_closed_only=1">Show 'Billing Not Closed' Only</a>
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="d-flex_ d-none flex-row">
                <div class="ml-2 mt-2">
                    <div>Patient</div>
                    <input type="text" class="form-control input-sm" name="patient">
                </div>
                <div class="ml-2 mt-2">
                    <div>HCP</div>
                    <input type="text" class="form-control input-sm" name="hcp">
                </div>
                <div class="ml-2 mt-2">
                    <div>Care Month Start Date</div>
                    <select name="" id="" class="form-control input-sm mb-2">
                        <option>all</option>
                        <option>on</option>
                        <option>on-or-before</option>
                        <option>on-or-after</option>
                        <option>between</option>
                        <option>not-on</option>
                        <option>not-in-between</option>
                    </select>
                    <input type="date1" class="form-control input-sm mb-2">
                    <input type="date1" class="form-control input-sm mb-2">
                </div>
                <div class="ml-2 mt-2">
                    <div>Number Of Days With Measurements</div>
                    <select name="" id="" class="form-control input-sm mb-2">
                        <option>all</option>
                        <option>less-than</option>
                        <option>greater-than</option>
                        <option>equal-to</option>
                        <option>between</option>
                        <option>not-equal-to</option>
                        <option>not-in-between</option>
                    </select>
                    <input type="date1" class="form-control form-control input-sm mb-2">
                    <input type="date1" class="form-control form-control input-sm mb-2">
                </div>
                <div class="ml-2 mt-2">
                    <div>Most Recent Mcp Note Date</div>
                    <select name="" id="" class="form-control  form-control input-sm mb-2">
                        <option>all</option>
                        <option>on</option>
                        <option>on-or-before</option>
                        <option>on-or-after</option>
                        <option>between</option>
                        <option>not-on</option>
                        <option>not-in-between</option>
                    </select>
                    <input type="date1" class="form-control input-sm mb-2">
                    <input type="date1" class="form-control input-sm mb-2">
                </div>
                <div class="ml-2 mt-2">
                    <div>Days Between Most Recent Mcp Note Date And End Of Care Month</div>
                    <select name="" id="" class="form-control input-sm mb-2">
                        <option>all</option>
                        <option>less-than</option>
                        <option>greater-than</option>
                        <option>equal-to</option>
                        <option>between</option>
                        <option>not-equal-to</option>
                        <option>not-in-between</option>
                    </select>
                    <input type="date1" class="form-control  input-sm mb-2">
                    <input type="date1" class="form-control  input-sm mb-2">
                </div>
                <div class="ml-2 mt-2">
                    <button class="btn btn-primary"><i class="fa fa-filter"></i> Filter</button>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-sm table-striped p-0 m-0" style="">
                    <thead class="bg-light text-nowrap">
                        <tr>
                            @if($isAdmin)
                            <th class="border-0">MCP</th>
                            @endif
                            <th class="border-0">Patient</th>
                            <th class="border-0">Month/Year</th>
                            <th class="border-0"># Days w/ Meas.</th>
                            <th class="border-0">Most Recent MCP Note</th>
                            <th class="border-0">Days Between Note and EOM</th>
                            @if($isAdmin)
                            <th class="border-0">RM Bill</th>
                            <th class="border-0">Is Bill Closed</th>
                            <th class="border-0">Bill Closed At</th>
                            <th class="border-0">Is Claim Closed</th>
                            @endif
                        </tr>
                    </thead>

                    <tbody>
                        @foreach($rows as $row)
                        <tr>
                            @if($isAdmin)
                            <td>
                                @if($row->mcp)
                                {{ implode(", ", [$row->mcp->name_display]) }}
                                @else
                                --
                                @endif
                            </td>
                            @endif
                            <td>
                                <a href="/patients/view/{{ $row->patient->uid }}">
                                    {{ implode(", ", [$row->patient->name_last,$row->patient->name_first]) }}
                                </a>
                            </td>
                            <td>
                                <a href="{{route('patients.view.care-months.view.dashboard', ['patient'=>$row->patient, 'careMonth'=>$row])}}">
                                    {{ friendly_date_month_year($row->start_date) }}
                                </a>
                            </td>
                            <td>
                                {{ $row->number_of_days_with_remote_measurements }}
                            </td>
                            <td>
                                @if($row->mostRecentMcpNote)
                                <a href="{{route('patients.view.notes.view.dashboard',['patient'=>$row->patient, 'note'=>$row->mostRecentMcpNote])}}">
                                    {{friendly_date($row->most_recent_mcp_note_date)}}
                                </a>
                                @else
                                --
                                @endif
                            </td>
                            <td>{{$row->days_between_most_recent_mcp_note_date_and_end_of_care_month}}</td>
                            @if($isAdmin)
                            <td>
                                @if($row->rmBill)
                                <a href="{{route('patients.view.care-months.view.dashboard', ['patient'=>$row->patient, 'careMonth'=>$row])}}">{{ $row->rmBill->code  }}</a>
                                @else
                                --
                                @endif
                            </td>
                            <td>{{$row->is_bill_closed? 'Yes':'No'}}</td>
                            <td>{{friendly_date_time($row->bill_closed_at)}}</td>
                            <td>{{$row->is_claim_closed? 'Yes':'No'}}</td>
                            @endif
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>

        </div>
    </div>
    <div class="mt-3">
        {{$rows->appends(request()->input())->links()}}
    </div>
</div>
@endsection