@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-user"></i>
                    Claims
                </strong>
                <a native href="{{route('practice-management.download-claims')}}" target="_blank">Download</a>
            </div>
            <div class="card-body p-0" moe>
                <form show url="/api/claimEDI/create">
                    <div class="my-1 mx-1">
                        <button submit class="btn bnt-sm btn-primary">Generate EDI</button>
                    </div>
                    <table class="table table-sm table-striped p-0 m-0">
                        <thead class="bg-light">
                        <tr>
                            <th></th>
                            <th class="border-0">#</th>
                            <th>Client</th>
                            <th>Submitted?</th>
                            <th class="border-0">Lines</th>
                            <th class="px-3 border-0">Created</th>
                        </tr>
                        </thead>
                        <tbody>

                        @foreach ($claims as $claim)
                            <tr>
                                <td>
                                    <input type="checkbox" name="claimUids[{{$loop->index}}]" value="{{$claim->uid}}">
                                </td>
                                <td>{{$claim->iid}}</td>
                                <td>{{$claim->client->name_first}} {{$claim->client->name_last}}</td>
                                <td>{{$claim->was_submitted?'Yes':'No'}}</td>
                                <td>
                                    <strong>Claim Lines</strong>
                                    <table class="table table-sm table-striped">
                                        <tr>
                                            <th>CPT</th>
                                            <th>ICDs</th>
                                            <th>Date of Service</th>
                                        </tr>
                                        @foreach($claim->lines as $claimLine)
                                            <tr>
                                                <td>{{$claimLine->cpt}}</td>
                                                <td>{{$claimLine->icds()}}</td>
                                                <td>{{$claimLine->date_of_service}}</td>
                                            </tr>
                                        @endforeach
                                    </table>
                                </td>
                                <td>{{$claim->created_at}}</td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </form>

            </div>
        </div>
        <div class="card">
            <div class="card-header">Claim EDIs</div>
            <div class="card-body">
                <table class="table table-sm table-striped">
                    <thead>
                    <tr>
                        <th>Created At</th>
                        <th>Claims</th>
                        <th>EDI File</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($claimEDIs as $edi)
                        <tr>
                            <td>{{$edi->created_at}}</td>
                            <td>
                                <table class="table table-sm table-striped p-0 m-0">
                                    <thead class="bg-light">
                                    <tr>
                                        <th class="border-0">#</th>
                                        <th>Client</th>
                                        <th>Submitted?</th>
                                        <th class="border-0">Lines</th>
                                        <th class="px-3 border-0">Created</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    @foreach ($edi->claims as $claim)
                                        <tr>
                                            <td>{{$claim->iid}}</td>
                                            <td>{{$claim->client->name_first}} {{$claim->client->name_last}}</td>
                                            <td>{{$claim->was_submitted?'Yes':'No'}}</td>
                                            <td>
                                                <strong>Claim Lines</strong>
                                                <table class="table table-sm table-striped">
                                                    <tr>
                                                        <th>CPT</th>
                                                        <th>ICDs</th>
                                                        <th>Date of Service</th>
                                                    </tr>
                                                    @foreach($claim->lines as $claimLine)
                                                        <tr>
                                                            <td>{{$claimLine->cpt}}</td>
                                                            <td>{{$claimLine->icds()}}</td>
                                                            <td>{{$claimLine->date_of_service}}</td>
                                                        </tr>
                                                    @endforeach
                                                </table>
                                            </td>
                                            <td>{{$claim->created_at}}</td>
                                        </tr>
                                    @endforeach
                                    </tbody>
                                </table>
                            </td>
                            <td>
                                <a native href="/api/claimEDI/download/{{$edi->uid}}" target="_blank">Download EDI File</a>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>

@endsection
