@extends ('layouts/template')

@section('content')

	<style>tr.bgyellow td, tr.bgyellow th { background-color: lightyellow; }</style>
	<style>tr.bggreen td, tr.bggreen th { background-color: #caffca; }</style>
	<style>tr.bgblue td, tr.bgblue th { background-color: #d0f2fd; }</style>
	<style>tr.claim-closed td:not(:first-child), tr.claim-closed th:not(:first-child) { background-color: lightgray; }</style>

    <div id="notes-resolution-center" class="p-3 mcp-theme-1">

        <div class="d-flex align-items-baseline">
            <h6 class="font-size-16 font-weight-bold text-secondary mb-3">Notes Resolution Center</h6>
            <form class="ml-5 d-inline-flex align-items-center" action="{{route('practice-management.notes-resolution-center')}}" method="GET">
                <span class="">Farah:</span>
                <select name="f" class="form-control form-control-sm min-width-unset max-width-110px ml-2"
                        onchange="fastLoad('{{route('practice-management.notes-resolution-center')}}?' + $(this).closest('form').serialize()); return false;">
                    <option value="">Any</option>
                    <option {{ request()->input('f') === 'green' ? 'selected' : '' }} value="green">Green</option>
                    <option {{ request()->input('f') === 'red' ? 'selected' : '' }} value="red">Red</option>
                </select>
                <span class=" ml-3">Shawn:</span>
                <select name="s" class="form-control form-control-sm min-width-unset max-width-110px ml-2"
                        onchange="fastLoad('{{route('practice-management.notes-resolution-center')}}?' + $(this).closest('form').serialize()); return false;">
                    <option value="">Any</option>
                    <option {{ request()->input('s') === 'green' ? 'selected' : '' }} value="green">Green</option>
                    <option {{ request()->input('s') === 'red' ? 'selected' : '' }} value="red">Red</option>
                </select>
            </form>
        </div>

        <table class="table table-sm table-bordered table-striped">
            <thead>
            <tr>
                <th class="border-bottom-0 text-nowrap text-right pr-2">V#</th>
                <th class="border-bottom-0 text-nowrap">Name</th>
                <th class="border-bottom-0 text-nowrap">MCP</th>
                <th class="border-bottom-0 text-nowrap d-none">NA</th>
                <th class="border-bottom-0 text-nowrap d-none">Chart #</th>
                <th class="border-bottom-0 text-nowrap">Date</th>
                <th class="border-bottom-0 text-nowrap">Minutes</th>
                <th class="border-bottom-0 text-nowrap">Note ICDs</th>
                <th class="border-bottom-0 text-nowrap">Note Link</th>
                <th class="border-bottom-0 text-nowrap"></th>
                <th class="border-bottom-0 text-nowrap"></th>
                <th class="border-bottom-0 text-nowrap">Farah Green?</th>
                <th class="border-bottom-0 text-nowrap">Shawn Review?</th>
                <th class="border-bottom-0 text-nowrap">Memo to Shawn</th>
                <th class="border-bottom-0 text-nowrap">Shawn Green?</th>
                <th class="border-bottom-0 text-nowrap">Shawn Reject?</th>
                <th class="border-bottom-0 text-nowrap">Claiming Closed?</th>
                <th class="border-bottom-0 text-nowrap d-none">Kyle Billed?</th>
                <th class="border-bottom-0 w-50 d-none"></th>
            </tr>
            </thead>
            <tbody>
            @foreach($rows as $row)
                @php
		    $visitCount = $row->visit_number;
                    $parsedDetailJson = new stdClass();
                    if($row->detail_json) {
                        try {
                            $parsedDetailJson = json_decode($row->detail_json);
                        }
                        catch (Exception $e) {}
                    }
                @endphp
                <tr class="{{ $row->visit_number > 2 ? 'bgyellow':'' }} {{ $row->visit_number == 1 ? 'bggreen':'' }} {{ $row->visit_number == 2 ? 'bgblue':'' }} {{ $row->is_claim_closed ? 'claim-closed' : '' }}">
                    <td class="text-nowrap text-right pr-2">{{$row->visit_number}}</td>
                    <td class="text-nowrap"><a href="/patients/view/{{$row->client_uid}}">{{$row->client_name}}</a></td>
                    <td class="text-nowrap">{{$row->hcp_name}}</td>
                    <td class="text-nowrap d-none">{{$row->na_name}}</td>
                    <td class="text-nowrap d-none">{{$row->chart_number}}</td>
                    <td class="text-nowrap">{{friendly_date($row->effective_dateest)}}</td>
                    <td class="text-nowrap">{{ $row->minutes }}</td>
                    <td class="">
                        @if($row->icd1) <div class="grow-till-300px">{{$row->icd1}} {{$row->icd1description}}</div>@endif
                        @if($row->icd2) <div class="grow-till-300px">{{$row->icd2}} {{$row->icd2description}}</div>@endif
                        @if($row->icd3) <div class="grow-till-300px">{{$row->icd3}} {{$row->icd3description}}</div>@endif
                        @if($row->icd4) <div class="grow-till-300px">{{$row->icd4}} {{$row->icd4description}}</div>@endif
                        @if($row->icd_memo) <div class="grow-till-300px">{{$row->icd_memo}}</div>@endif
                    </td>
                    <td class="text-nowrap">
                        <a open-in-stag-popup popup-style="medium-large" update-parent
                           mc-initer="note-resolve-{{$row->uid}}"
                           title="Note: {{$row->client_name}}  -  {{friendly_date($row->effective_dateest)}} - Visit# {{$row->visit_number}}"
                           href="/resolve-note/{{$row->client_uid}}/{{$row->uid}}">View</a>&nbsp;
			            <a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on" target="popup" onclick="window.open("/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on",'popup','width=600,height=600,scrollbars=no,resizable=no'); return false;"><i class="fa fa-arrow-right"></i></a>
                    </td>
                    <td>
			@if(!$row->is_claim_closed)
                            <div moe>
                                <a start show>Submit claim</a>
                                <form url="/api/note/processNoteShortcut">
                                    <input type="hidden" name="uid" value="{{$row->uid}}">
                                    <div class="form-group mb-2">
                                        <p>Are you sure?</p>
                                    </div>
                                    <div class="form-group m-0">
                                        <button submit class="btn btn-primary btn-sm">submit</button>
                                        <button cancel class="btn btn-primary btn-sm">cancel</button>
                                    </div>
                                </form>
                            </div>
			@endif
                    </td>
                    <td>
                        @if($row->visit_number == 1 && !$row->is_claim_closed)
                            <div moe>
                                <form show url="/api/note/processVisit1ForCovidIntake">
                                    <input type="hidden" name="uid" value="{{$row->uid}}">
                                    <div class="form-group mb-2 d-none">
                                        <p>Are you sure?</p>
                                    </div>
                                    <div class="form-group m-0">
                                        <button submit class="btn btn-danger btn-sm" process-intake="true">Process Intake</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </td>
                    <td class="font-weight-bold text-success">{!! @$parsedDetailJson->farah_decision && @$parsedDetailJson->farah_decision === 'green' ? '<i class="fa fa-check"></i> Yes' : '' !!}</td>
                    <td class="font-weight-bold text-warning-dark">{!! @$parsedDetailJson->farah_decision && @$parsedDetailJson->farah_decision === 'red' ? '<i class="fa fa-exclamation-triangle"></i> Yes' : '' !!}</td>
                    <td class="font-weight-bold">{{ @$parsedDetailJson->memo_to_shawn }}</td>
                    <td class="font-weight-bold text-success">{!! @$parsedDetailJson->shawn_decision && @$parsedDetailJson->shawn_decision === 'green' ? '<i class="fa fa-check"></i> Yes' : '' !!}</td>
                    <td class="font-weight-bold text-danger">{!! @$parsedDetailJson->shawn_decision && @$parsedDetailJson->shawn_decision === 'red' ? '<i class="fa fa-times"></i> Rejected' : '' !!}</td>
                    <td class="font-weight-bold text-success">{{ $row->is_claim_closed }}</td>
                    <td class="font-weight-bold text-success d-none">{!! @$parsedDetailJson->kyle_billed && @$parsedDetailJson->kyle_billed === 'yes' ? '<i class="fa fa-check"></i> Yes' : '' !!}</td>
                    
                    <td class="d-none">
		            {{--
			<a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on" target="popup"
				onclick="window.open("/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on",'popup','width=600,height=600,scrollbars=no,resizable=no'); return false;"></a>

                        <a open-in-stag-popup update-parent title="Note: {{$row->client_name}}  -  {{friendly_date($row->effective_dateest)}} - SUGGESTION MODE"
				href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on">Go to note</a>
                    </td>
                    --}}
                </tr>
            @endforeach
            </tbody>
        </table>

        <div class="d-flex align-items-baseline">
            {!! $paginator->withQueryString()->links() !!}
            <div class="mb-3">
                <div class="ml-4 mb-3">Showing <b>{{$paginator->firstItem()}}</b> to <b>{{$paginator->lastItem()}}</b> (page {{$paginator->currentPage()}}) of <b>{{$paginator->total()}}</b> notes</div>
            </div>
        </div>

    </div>

@endsection
