@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 d-inline-block">
                    <i class="fas fa-chart-bar"></i>
                    Key numbers
                </strong>
            </div>
            <div class="card-body p-0 border-0">
                <table class="table mb-0 table-sm table-bordered table-striped">
                    <tbody>
                    <tr>
                        <th class="border-top-0 pl-2" style="width: 300px;">Total notes</th>
                        <td class="border-top-0 px-2"  style="width: 100px;">{{$notesTotal}}</td>
                        <td></td>
                    </tr>
                    <tr>
                        <th class="pl-2">Notes with billing closed</th>
                        <td class="px-2">{{$notesTotalWithBillingClosed}} / {{ $notesTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($notesTotalWithBillingClosed) *100/ $notesTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithBillingClosed) * 100/ $notesTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="pl-2">Notes with claiming closed</th>
                        <td class="px-2">{{$notesTotalWithClaimingClosed}} / {{ $notesTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($notesTotalWithClaimingClosed) *100/ $notesTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithClaimingClosed) * 100/ $notesTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <th class="border-top-0 pl-2" style="width: 300px;">Total notes, 3rd party</th>
                        <td class="border-top-0 px-2"  style="width: 100px;">{{$notes3rdPartyTotal}}</td>
                        <td></td>
                    </tr>
                    <tr>
                        <th class="pl-2">Notes with billing closed, 3rdParty</th>
                        <td class="px-2">{{$notes3rdPartyTotalWithBillingClosed}} / {{ $notes3rdPartyTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($notes3rdPartyTotalWithBillingClosed) *100/ $notes3rdPartyTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithBillingClosed) * 100/ $notesTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="pl-2">Notes with claiming closed, 3rdParty</th>
                        <td class="px-2">{{$notes3rdPartyTotalWithClaimingClosed}} / {{ $notes3rdPartyTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($notes3rdPartyTotalWithClaimingClosed) *100/ $notes3rdPartyTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithClaimingClosed) * 100/ $notesTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <th class="border-top-0 pl-2" style="width: 250px;">Total patients w/ notes</th>
                        <td class="border-top-0 px-2"  style="width: 100px;">{{$patientsTotal}}</td>
                        <td></td>
                    </tr>
                    <tr>
                        <th class="pl-2">Patients with notes & billing closed</th>
                        <td class="px-2">{{$patientsTotalWithBillingClosed}} / {{ $patientsTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($patientsTotalWithBillingClosed) *100/ $patientsTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($patientsTotalWithBillingClosed) * 100/ $patientsTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="pl-2">Patients with notes & claiming closed</th>
                        <td class="px-2">{{$patientsTotalWithClaimingClosed}} / {{ $patientsTotal }}</td>
                        <td>
                            <div class="d-flex align-items-center">
                                <span class="fill-percent-value">{{round(($patientsTotalWithClaimingClosed) *100/ $patientsTotal, 1)}}%</span>
                                <div class="flex-grow-1 position-relative fill-bar">
                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($patientsTotalWithClaimingClosed) * 100/ $patientsTotal }}%"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

	<style>
		tr.zero td {
			background-color: grey !important;
		}
	</style>

    <div id="practice-bills" class="px-3 mcp-theme-1">
        <div class="card">

            <div class="card-header px-2 py-1 d-flex align-items-center">
                <strong class="mr-4 d-inline-block">
                    <i class="fas fa-user"></i>
                    Patient Claim Summary
                </strong>
                <select class="ml-auto max-width-300px form-control form-control-sm d-inline-block"
                        onchange="fastLoad('/practice-management/patient-claim-summary/' + this.value, true, false, false)">
                    <option value="" {{ $proUid === '' ? 'selected' : '' }}>All Pros</option>
                    @foreach($allPros as $_pro)
                        <option
                            value="{{$_pro->uid}}" {{ $proUid === $_pro->uid ? 'selected' : '' }}>{{$_pro->displayName()}}</option>
                    @endforeach
                </select>
            </div>
            <div class="card-body p-0 border-0">
                <table class="table table-striped table-condensed table-sm">
                    <thead>
                    <tr>
                        <th>Patient</th>
                        <th>MCP</th>
                        <th>Coverage</th>
                        <th>#Notes without Billing Closed</th>
                        <th>#Notes without Claiming Closed</th>
                        <th>#Notes Total</th>
                        <th>% Notes with Claiming Closed</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($patients as  $patient)
                        <tr class="{{ $patient->notes_total == 0 ? 'zero' : ''}}">
                            <td>
                                <a native target="_blank"
                                   open-in-stag-popup
                                   update-parent
                                   title="{{$patient->name_first}} {{$patient->name_last}} - Claims Resolver"
                                   href="{{route('patients.view.claims-resolver', $patient->uid)}}">
                                    {{$patient->name_first}} {{$patient->name_last}}
                                </a>
                            </td>
                            <td>{{$patient->mcp}}</td>
                            <td>
                                <?php $coverageStatus = $patient->getPrimaryCoverageStatus(); ?>
                                @if($coverageStatus === 'YES')
                                    <div class="text-nowrap">Covered <i class="fa fa-check-circle text-success"></i>
                                    </div>
                                @elseif($coverageStatus === 'NO')
                                    <div class="text-nowrap">Not Covered <i class="fa fa-times text-danger"></i></div>
                                @else
                                    <div class="text-nowrap">Unknown <i
                                                class="fa fa-exclamation-triangle text-warning-mellow"></i></div>
                                @endif
                                <?php $coverage = $patient->getPrimaryCoverage(); ?>
                                @if($coverage)
                                    {{$coverage->insuranceDisplayName()}}
                                @endif
                            </td>
                            <td>{{$patient->notes_without_billing_closed}}</td>
                            <td>{{$patient->notes_without_claiming_closed}}</td>
                            <td>{{$patient->notes_total}}</td>
                            <td>
                                <div class="d-flex align-items-center">
                                    <span class="fill-percent-value">{{$patient->notes_total ? round(($patient->notes_total - $patient->notes_without_claiming_closed) *100/ $patient->notes_total, 1) : '-'}}%</span>
                                    <div class="flex-grow-1 position-relative fill-bar">
                                        <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ $patient->notes_total ? ($patient->notes_total - $patient->notes_without_claiming_closed ) * 100 / $patient->notes_total : '-'}}%"></div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <div>
                    {{$patients->links()}}
                </div>
            </div>
        </div>
    </div>

@endsection
