<div id="cpp-bills-claims-container" moe-refresh-container>

    {{-- companyPro, payer and location --}}
    @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
    <div class="p-3 border-bottom screen-only" data-non-segment-section="Pro/Payer Settings">
        <div class="">

            <div class="d-flex align-items-baseline mb-1">
                <div class="text-secondary mb-1">Company Pro:&nbsp;</div>
                <div class="">
                    <b>{{$note->hcpCompanyPro && $note->hcpCompanyPro->company ? $note->hcpCompanyPro->pro->displayName() . ' / ' . $note->hcpCompanyPro->company->name : '-'}}</b>
                    @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)
                        <div moe class="ml-1">
                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                            <form url="/api/note/wipeHcpCompanyPro">
                                <input type="hidden" name="uid" value="{{$note->uid}}">
                                <p>Wipe company pro from this note?</p>
                                <div class="mb-0">
                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    @else
                        <div moe class="ml-1">
                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                            <form url="/api/note/putHcpCompanyPro">
                                <input type="hidden" name="uid" value="{{$note->uid}}">
                                <div class="mb-2">
                                    <select name="hcpCompanyProUid" class="form-control form-control-sm">
                                        <option value="">-- select --</option>
                                        @if($note->hcpPro)
                                            @foreach($note->hcpPro->companyPros as $companyPro)
                                                <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
                                            @endforeach
                                        @endif
                                    </select>
                                </div>
                                <div class="mb-0">
                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    @endif
                </div>
            </div>

            @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)

                <div class="d-flex align-items-baseline mb-1">
                    <div class="text-secondary mb-1">Payer 1°:&nbsp;</div>
                    <div class="">
                        <b>{{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer ? $note->hcpCompanyProPayer->payer->name : '-'}}</b>
                        @if($note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer)
                            <div moe class="ml-1">
                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                <form url="/api/note/wipeHcpCompanyProPayer">
                                    <input type="hidden" name="uid" value="{{$note->uid}}">
                                    <p>Wipe payer from this note?</p>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @else
                            <div moe class="ml-1">
                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                <form url="/api/note/putHcpCompanyProPayer">
                                    <input type="hidden" name="uid" value="{{$note->uid}}">
                                    <div class="mb-2">
                                        <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
                                            <option value="">-- select --</option>
                                            @foreach($note->hcpCompanyPro->companyProPayers as $companyProPayer)
                                                <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </div>
                </div>

                <div class="d-flex align-items-baseline mb-1">
                    <div class="text-secondary mb-1">Payer 2°:&nbsp;</div>
                    <div class="">
                        <b>-</b>
                    </div>
                </div>

                <div class="d-flex align-items-baseline mb-1">
                    <div class="text-secondary mb-1">Location:&nbsp;</div>
                    <div class="">
                        <b>{{$note->hcpCompanyLocation ? $note->hcpCompanyLocation->line1 . ', ' . $note->hcpCompanyLocation->city : '-'}}</b>
                        @if($note->hcpCompanyLocation)
                            <div moe class="ml-1">
                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                <form url="/api/note/wipeHcpCompanyLocation">
                                    <input type="hidden" name="uid" value="{{$note->uid}}">
                                    <p>Wipe location from this note?</p>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @else
                            <div moe class="ml-1">
                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                <form url="/api/note/putHcpCompanyLocation">
                                    <input type="hidden" name="uid" value="{{$note->uid}}">
                                    <div class="mb-2">
                                        <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
                                            <option value="">-- select --</option>
                                            @if($note->hcpCompany && $note->hcpCompany->locations)
                                                @foreach($note->hcpCompany->locations as $location)
                                                    <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
                                                @endforeach
                                            @endif
                                        </select>
                                    </div>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </div>
                </div>
            @endif

            <div class="d-flex align-items-baseline">
                <div class="text-secondary font-weight-normal">Primary Coverage:&nbsp;</div>
                <b class="d-inline-flex">@include('app.patient.coverage_column_renderer', ['patient'=>$patient, 'truncateName' => true])</b>
            </div>
        </div>
    </div>
    @endif

    {{-- bills --}}
    @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
        <div class="screen-only" data-non-segment-section="HCP Bills">
        @if($note->bills->count())
            <div class="p-3 border-bottom">
        <div class="d-flex align-items-center mb-2">
            <p class="font-weight-bold text-secondary font-size-13 m-0">Bills</p>
            @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
                @include('app/patient/note/_create-bill')
            @endif
        </div>

        @if($pro->pro_type === 'ADMIN')
        <table class="table table-sm tabe-striped mb-0 table-bordered">
            <thead class="bg-light">
            <tr class="text-secondary">
                <?php /* <th class="border-bottom-0"></th> */ ?>
                <th class="border-bottom-0">Date</th>
                <th class="border-bottom-0">Service</th>
                <th class="border-bottom-0">Billable</th>
                <th class="border-bottom-0">HCP</th>
                <th class="border-bottom-0 screen-only">Total</th>
                <th class="border-bottom-0">Sign</th>
                <th class="border-bottom-0 screen-only">Bal Post Date</th>
                <th class="border-bottom-0">Verification</th>
                <th class="border-bottom-0">Cancellation</th>
                <th class="border-bottom-0 screen-only">Payment</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($note->bills as $bill)
                <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
                    <?php /* <td class="p-0">
                        <table class="table-striped table-sm table-condensed border border-left-0 border-top-0 border-bottom-0">
                            <tbody>
                                <tr><td>collected_amount</td><td>{{$bill->collected_amount}}</td></tr>
                                <tr><td>effective_date</td><td>{{$bill->effective_date}}</td></tr>
                                <tr><td>has_hcp_been_paid</td><td>{{$bill->has_hcp_been_paid}}</td></tr>
                                <tr><td>hcp_expected_payment_amount</td><td>{{$bill->hcp_expected_payment_amount}}</td></tr>
                                <tr><td>hcp_payment_amount</td><td>{{$bill->hcp_payment_amount}}</td></tr>
                                <tr><td>is_cancelled</td><td>{{$bill->is_cancelled}}</td></tr>
                                <tr><td>hcp_payment_pro_transaction_id</td><td>{{$bill->hcp_payment_pro_transaction_id}}</td></tr>
                                <tr><td>balance_post_date</td><td>{{$bill->balance_post_date}}</td></tr>
                                <tr><td>is_verified</td><td>{{$bill->is_verified}}</td></tr>
                                <tr><td>is_cancellation_acknowledged</td><td>{{$bill->is_cancellation_acknowledged}}</td></tr>
                                <tr><td>is_cancelled_by_administrator</td><td>{{$bill->is_cancelled_by_administrator}}</td></tr>
                                <tr><td>total_expected</td><td>{{$bill->total_expected}}</td></tr>
                                <tr><td>total_paid</td><td>{{$bill->total_paid}}</td></tr>
                            </tbody>
                        </table>
                    </td> */ ?>
                    <td class="text-nowrap">{{friendlier_date_time($bill->effective_date, false)}}</td>
                    <td>{{$bill->code}}</td>
                    <td class="">
                        @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
                            <?php
                            $totalSeconds = $bill->number_of_units * 3600;
                            $remainder = $totalSeconds % 60;
                            if ($remainder !== 0) {
                                if ($remainder < 30) {
                                    $totalSeconds = $totalSeconds - $remainder;
                                } else {
                                    $totalSeconds = $totalSeconds + (60 - $remainder);
                                }
                            }
                            ?>
                            {{ time_in_hrminsec($totalSeconds) }}
                        @else
                            @if(!!$bill->number_of_units)
                                {{ $bill->number_of_units }} unit(s)
                            @else
                                -
                            @endif
                        @endif
                    </td>
                    <td class="">
                        <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }} (HCP)</div>
                        <div class="text-nowrap mt-1 screen-only">
                            <span class="text-secondary">Paid: </span>
                            <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
                        </div>
                        @if(!$bill->has_hcp_been_paid)
                            <div class="text-nowrap mt-1 screen-only">
                                <span class="text-secondary">Expected: </span>
                                <span class="font-weight-bold">${{ $bill->hcp_expected_payment_amount }}</span>
                            </div>
                        @else
                            <div class="text-nowrap mt-1 screen-only">
                                <span class="text-secondary">Amount: </span>
                                <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
                            </div>
                        @endif
                        @if($bill->ally && !!floatval($bill->na_expected_payment_amount))
                            <hr>
                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->ally->displayName() }} (NA)</div>
                            <div class="text-nowrap mt-1 screen-only">
                                <span class="text-secondary">Paid: </span>
                                <span>{{ $bill->has_na_been_paid ? 'Yes' : 'No' }}</span>
                            </div>
                            @if(!$bill->has_na_been_paid)
                                <div class="text-nowrap mt-1 screen-only">
                                    <span class="text-secondary">Expected: </span>
                                    <span class="font-weight-bold">${{ $bill->na_expected_payment_amount }}</span>
                                </div>
                            @else
                                <div class="text-nowrap mt-1 screen-only">
                                    <span class="text-secondary">Amount: </span>
                                    <span class="font-weight-bold">${{ $bill->na_payment_amount }}</span>
                                </div>
                            @endif
                        @endif

                        @if($pro->pro_type === 'ADMIN')
                            <b>{{$bill->hcpCompanyPro && $bill->hcpCompanyPro->company ? $bill->hcpCompanyPro->pro->displayName() . ' / ' . $bill->hcpCompanyPro->company->name : '-'}}</b>
                            <div moe class="ml-1">
                                <a class="text-primary" href="" show start>Swap HCP Company Pro</a>
                                <form url="/api/bill/swapHcpCompanyPro">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <div class="mb-2">
                                        <select name="hcpCompanyProUid" class="form-control form-control-sm">
                                            <option value="">-- select --</option>
                                            @foreach($bill->hcp->companyPros as $companyPro)
                                                <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                        <div>
                            @include('app.patient.note.flag-bill')
                        </div>

                    </td>
                    <td class="pr-3 screen-only">
                        @if($bill->has_hcp_been_paid)
                            <span class="text-secondary">Paid. </span>
                            <span class="font-weight-bold">${{ friendly_money($bill->total_paid) }}</span>
                        @else
                            <span class="text-secondary">Exp. </span>
                            <span class="font-weight-bold">{{ $bill->total_expected ? '$' . friendly_money($bill->total_expected) : '-' }}</span>
                        @endif
                    </td>
                    <td>
                        @if(!$bill->is_cancelled)
                            @if($bill->is_signed_by_hcp)
                                <span class="d-block text-secondary text-nowrap">
                                        <i class="fa fa-check"></i>
                                        HCP Signed
                                    </span>
                            @else
                                <span moe
                                      class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
                                      title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
                                    <a class="" href="" show start>Sign As HCP</a>
                                    <form url="/api/bill/signAsHcp">
                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
                                        <p>Sign this bill as HCP?</p>
                                        <div class="mb-0">
                                            <button class="btn btn-success btn-sm" submit>Sign</button>
                                            <button class="btn btn-default border btn-sm"
                                                    cancel>Cancel</button>
                                        </div>
                                    </form>
                                </span>
                            @endif

                            @if($bill->is_signed_by_na)
                                <span class="d-block text-secondary text-nowrap">
                                    <i class="fa fa-check"></i>
                                    NA Signed
                                </span>
                            @else
                                <span moe
                                      class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
                                      title="{{ $bill->na_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
                                    <a class="" href="" show start>Sign As NA</a>
                                    <form url="/api/bill/signAsNa">
                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
                                        <p>Sign this bill as NA?</p>
                                        <div class="mb-0">
                                            <button class="btn btn-success btn-sm" submit>Sign</button>
                                            <button class="btn btn-default border btn-sm"
                                                    cancel>Cancel</button>
                                        </div>
                                    </form>
                                </span>
                            @endif
                        @endif
                    </td>
                    <td class="screen-only">
                        @if(!$bill->is_cancelled)
                            <span class="d-block" moe>
                                <a class="" href="" show start>
                                    {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
                                </a>
                                <form url="/api/bill/updateBalancePostDate">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <p>Update Balance Post Date</p>
                                    <div class="mb-0">
                                        <input type="date" class="text form-control form-control-sm"
                                               name="balancePostDate"
                                               value="{{$bill->balance_post_date}}"
                                               placeholder="balance post date"><br>
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm"
                                                cancel>Cancel</button>
                                    </div>
                                </form>
                            </span>
                        @endif
                    </td>
                    <td> <!-- verification -->
                        @if(!$bill->hcpCompanyPro)
                            <div class="mb-1 text-danger">
                                <i class="fa fa-exclamation-triangle"></i>
                                Company Pro isn't set on the bill
                            </div>
                        @else
                            @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
                                @if(!$bill->is_verified)
                                    <div class="text-warning-mellow font-weight-bold">Not Verified</div>
                                    <span class="d-block mt-1" moe>
                                        <a href="" show start>Mark Verified</a>
                                        <form url="/api/bill/markAsVerified">
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Mark As Verfified?</p>
                                            <div class="mb-0">
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm"
                                                        cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                @else
                                    <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
                                    <div class="text-muted">By: {{@$bill->markedVerifiedBySession && @$bill->markedVerifiedBySession->pro ? @$bill->markedVerifiedBySession->pro->displayName() : '-'}} on {{friendly_date_time(@$bill->marked_verified_at)}}</div>
                                    <span class="d-block mt-1" moe>
                                        <a class="" href="" show start>Undo</a>
                                        <form url="/api/bill/undoMarkAsVerified">
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Undo Mark As Verfified?</p>
                                            <div class="mb-0">
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm"
                                                        cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                @endif
                            @endif
                        @endif
                    </td>
                    <td>  <!-- cancellation -->
                        @if($bill->is_cancelled)
                            <div class="text-warning-mellow font-weight-bold">Cancelled</div>
                            @if($bill->cancellation_memo)
                                <div class="text-dark text-sm font-italic my-1">{{$bill->cancellation_memo}}</div>
                            @endif
                            @if($bill->is_cancelled_by_administrator)
                                <div class="text-secondary text-sm">(by Administrator)</div>
                            @endif
                            <div moe class="mt-1">
                                <a class="" href="" show start>Update Memo</a>
                                <form url="/api/bill/updateCancellationMemo">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <p>Update Cancellation Memo</p>
                                    <div class="mb-2">
                                        <textarea class="text form-control form-control-sm"
                                                  name="cancellationMemo"
                                                  placeholder="">{{$bill->cancellation_memo ? $bill->cancellation_memo : 'Please contact billing.'}}</textarea>
                                    </div>
                                    <div>
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm"
                                                cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @else
                            <span class="d-block" moe relative="">
                                <a class="text-danger" href="" show start>Cancel</a>
                                <form url="/api/bill/markCancelled" right="">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <p class="mb-2">Cancel this bill?</p>
                                    <div class="mb-2">
                                        <label class="mb-1 text-secondary">Cancellation Memo</label>
                                        <textarea type="text" name="memo" placeholder="Memo"
                                                  class="form-control form-control-sm">Please contact billing.</textarea>
                                    </div>
                                    <div class="mb-0">
                                        <button class="btn btn-danger btn-sm" submit>Yes</button>
                                        <button class="btn btn-default border btn-sm" cancel>No</button>
                                    </div>
                                </form>
                            </span>
                        @endif

                        @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
                            <div class="mt-2 text-secondary">
                                <i class="fa fa-exclamation-triangle"></i>
                                Not Ack.
                            </div>
                            <div class="d-block mt-1" moe>
                                <a class="" href="" show start>Ack. Cancellation</a>
                                <form url="/api/bill/acknowledgeCancellation">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <p>Acknowledge Cancellation?</p>
                                    <div class="mb-0">
                                        {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm"
                                                cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif

                        @if($bill->is_cancellation_acknowledged && !$note->is_billing_marked_done)
                            <div class="mt-2 text-secondary">
                                <i class="fa fa-check"></i>
                                Ack.
                            </div>
                            <div class="d-block mt-1" moe>
                                <a class="" href="" show start>Undo Cancellation Ack.</a>
                                <form url="/api/bill/undoAcknowledgeCancellation">
                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
                                    <p>Undo Acknowledge Cancellation?</p>
                                    <div class="mb-0">
                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                        <button class="btn btn-default border btn-sm"
                                                cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif

                    </td>
                    <td class="screen-only"> <!-- submit payment -->
                        <div class="my-1">
                            @if(!$bill->is_cancelled && !$bill->has_hcp_been_paid )
                                @if(+$bill->hcp_expected_payment_amount && $bill->is_signed_by_hcp)
                                    <span class="d-block" moe relative="">
                                        <a class="font-weight-bold" href="" show start>Submit Payment For HCP</a>
                                        <form url="/api/bill/payHcpAmount" right>
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Submit Payment</p>
                                            <div class="mb-0">
                                                <input type="text"
                                                       class="text form-control form-control-sm"
                                                       name="hcpPaymentAmount"
                                                       value="{{$bill->hcp_expected_payment_amount}}"
                                                       placeholder="amount"><br>
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                @else
                                    @if(!+$bill->hcp_expected_payment_amount)
                                        <div class="mb-1 text-danger">
                                            <i class="fa fa-exclamation-triangle"></i>
                                            HCP expected amount is invalid
                                        </div>
                                    @endif
                                    @if(!$bill->is_signed_by_hcp)
                                        <div class="mb-1 text-danger">
                                            <i class="fa fa-exclamation-triangle"></i>
                                            HCP has not signed the bill
                                        </div>
                                    @endif
                                @endif
                            @endif
                        </div>
                        <div class="my-1">
                            @if(!$bill->is_cancelled && !$bill->has_na_been_paid && $bill->ally)
                                @if(+$bill->na_expected_payment_amount && $bill->is_signed_by_na)
                                    <span class="d-block" moe relative="">
                                        <a class="font-weight-bold" href="" show start>Submit Payment For NA</a>
                                        <form url="/api/bill/payNaAmount" right>
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Submit Payment For NA</p>
                                            <div class="mb-0">
                                                <input type="text"
                                                       class="text form-control form-control-sm"
                                                       name="naPaymentAmount"
                                                       value="{{$bill->na_expected_payment_amount}}"
                                                       placeholder="amount"><br>
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                @else
                                    @if(!+$bill->na_expected_payment_amount)
                                        <div class="mb-1 text-danger">
                                            <i class="fa fa-exclamation-triangle"></i>
                                            NA expected amount is invalid
                                        </div>
                                    @endif
                                    @if(!$bill->is_signed_by_na)
                                        <div class="mb-1 text-danger">
                                            <i class="fa fa-exclamation-triangle"></i>
                                            NA has not signed the bill
                                        </div>
                                    @endif
                                @endif
                            @endif
                        </div>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
                @elseif($note->hcpPro && $pro->id === $note->hcpPro->id)
                    <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
            <thead class="bg-light">
            <tr>
                <th class="border-bottom-0 pl-3">HCP</th>
                @if($note->ally_pro_id === $pro->id)
                    <th class="border-bottom-0 pl-3">NA</th>
                @endif
                <th class="border-bottom-0 w-25 pl-3">Service</th>
                <th class="border-bottom-0 pl-3">Billable</th>
                <th class="border-bottom-0 pl-2">Amount</th>
                <th class="border-bottom-0 pl-2">Verification</th>
                <th class="border-bottom-0"></th>
            </tr>
            </thead>
            <tbody>
            @foreach ($note->bills as $bill)
                <tr>
                    <td class="pl-3">{{ $bill->hcp->displayName() }}</td>
                    @if($note->ally_pro_id === $pro->id)
                        <td class="pl-3">{{ $note->allyPro->displayName() }}</td>
                    @endif
                    <td class="pl-3 {{ $bill->is_cancelled ? 'text-secondary' : '' }}">{{$bill->code}}</td>
                    <td class="pl-3">
                        @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
                            <?php
                            $totalSeconds = $bill->number_of_units * 3600;
                            $remainder = $totalSeconds % 60;
                            if ($remainder !== 0) {
                                if ($remainder < 30) {
                                    $totalSeconds = $totalSeconds - $remainder;
                                } else {
                                    $totalSeconds = $totalSeconds + (60 - $remainder);
                                }
                            }
                            ?>
                            {{ time_in_hrminsec($totalSeconds) }}
                        @else
                            @if(!!$bill->number_of_units)
                                {{ $bill->number_of_units }} unit(s)
                            @else
                                -
                            @endif
                        @endif
                    </td>
                    <td class="pl-2">
                        @if($bill->hcp_pro_id === $pro->id)
                            @if($bill->has_hcp_been_paid)
                                <span class="text-dark">Processed:</span><span
                                        class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
                            @else
                                <span class="text-dark">Expected:</span><span
                                        class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
                            @endif
                        @elseif($bill->na_pro_id === $pro->id)
                            @if($bill->has_na_been_paid)
                                <span class="text-dark">Processed:</span><span
                                        class="font-weight-bold text-success ml-2">${{ $bill->na_payment_amount }}</span>
                            @else
                                <span class="text-dark">Expected:</span><span
                                        class="font-weight-bold text-dark ml-2">{{ $bill->na_expected_payment_amount ? '$' . $bill->na_expected_payment_amount : '-' }}</span>
                            @endif
                        @endif
                    </td>
                    <td class="pl-2">
                        @if(!$bill->is_cancelled)
                            @if(!$bill->is_verified)
                                <div class="text-warning-mellow font-weight-bold">Not Verified</div>
                            @else
                                <div class="text-info font-weight-bold"><i class="fa fa-check"></i> Verified</div>
                            @endif
                        @endif
                    </td>
                    <td>
                        <div class="d-flex align-items-center">
                            @if(!$bill->is_cancelled)
                                @if($bill->is_signed_by_hcp)
                                    <span class="d-block text-secondary">
                                        <i class="fa fa-check"></i>
                                        HCP Signed
                                    </span>
                                @else
                                    <span moe
                                          class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
                                          title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
                                        <a class="" href="" show start>Sign as HCP</a>
                                        <form url="/api/bill/signAsHcp">
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Sign this bill as HCP?</p>
                                            <div class="mb-0">
                                                <button class="btn btn-success btn-sm"
                                                        submit>Sign</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                @endif
                                @if($bill->na_pro_id === $pro->id)
                                    <span class="mx-2 text-secondary">|</span>
                                    @if($bill->is_signed_by_na)
                                        <span class="d-block text-secondary">
                                            <i class="fa fa-check"></i>
                                            NA Signed
                                        </span>
                                    @else
                                        <span moe
                                              class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
                                              title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
                                            <a class="" href="" show start>Sign as NA</a>
                                            <form url="/api/bill/signAsNa">
                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
                                                <p>Sign this bill as NA?</p>
                                                <div class="mb-0">
                                                    <button class="btn btn-success btn-sm"
                                                            submit>Sign</button>
                                                    <button class="btn btn-default border btn-sm"
                                                            cancel>Cancel</button>
                                                </div>
                                            </form>
                                        </span>
                                    @endif
                                @endif
                            @endif
                            @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
                                <span class="mx-2 text-secondary">|</span>
                                <span class="d-block" moe>
                                    <a class="text-danger" href="" show start>Submit Payment</a>
                                    <form url="/api/bill/payHcpAmount">
                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
                                        <p>Submit payment:</p>
                                        <div class="mb-0">
                                            <input type="text" class="text form-control form-control-sm"
                                                   name="hcpPaymentAmount"
                                                   value="{{$bill->hcp_expected_payment_amount}}"
                                                   placeholder="amount"><br>
                                            <button class="btn btn-primary btn-sm"
                                                    submit>Submit</button>
                                            <button class="btn btn-default border btn-sm"
                                                    cancel>Cancel</button>
                                        </div>
                                    </form>
                                </span>
                            @endif
                            @if(!$bill->has_na_been_paid && $bill->ally && $pro->pro_type === 'ADMIN')
                                <span class="d-block" moe relative="">
                                    <a class="font-weight-bold" href="" show
                                       start>Submit Payment For NA</a>
                                    <form url="/api/bill/payNaAmount" right>
                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
                                        <p>Submit Payment For NA</p>
                                        <div class="mb-0">
                                            <input type="text" class="text form-control form-control-sm"
                                                   name="naPaymentAmount"
                                                   value="{{$bill->na_expected_payment_amount}}"
                                                   placeholder="amount"><br>
                                            <button class="btn btn-primary btn-sm"
                                                    submit>Submit</button>
                                            <button class="btn btn-default border btn-sm"
                                                    cancel>Cancel</button>
                                        </div>
                                    </form>
                                </span>
                            @endif
                            @if($bill->is_cancelled)
                                <span class="mx-2 text-secondary">|</span>
                                <span class="d-block text-secondary">
                                    Cancelled
                                </span>
                                @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
                                    <div class="ml-2 text-secondary">
                                        <i class="fa fa-exclamation-triangle"></i>
                                        Not Ack.
                                    </div>
                                    <div class="d-block ml-2" moe>
                                        <a class="" href="" show start>Ack. Cancellation</a>
                                        <form url="/api/bill/acknowledgeCancellation">
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Acknowledge Cancellation?</p>
                                            <div class="mb-0">
                                                {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </div>
                                @endif

                                @if($bill->is_cancellation_acknowledged && !$note->is_billing_marked_done)
                                    <div class="ml-2 text-secondary">
                                        <i class="fa fa-check"></i>
                                        Ack.
                                    </div>
                                    <div class="d-block ml-2" moe>
                                        <a class="" href="" show start>Undo</a>
                                        <form url="/api/bill/undoAcknowledgeCancellation">
                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
                                            <p>Undo Acknowledge Cancellation?</p>
                                            <div class="mb-0">
                                                <button class="btn btn-primary btn-sm"
                                                        submit>Submit</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </div>
                                @endif
                            @else
                                <span class="mx-2 text-secondary">|</span>
                                <span class="d-block" moe>
                                    <a class="text-danger" href="" show start>Cancel</a>
                                    <form url="/api/bill/markCancelled" right>
                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
                                        <p>Cancel this bill?</p>
                                        <div class="mb-0">
                                            <button class="btn btn-danger btn-sm" submit>Yes</button>
                                            <button class="btn btn-default border btn-sm"
                                                    cancel>No</button>
                                        </div>
                                    </form>
                                </span>
                            @endif
                        </div>
                        @include('app.patient.note.flag-bill')
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        @endif


    </div>
        @else
            <div class="p-3 d-flex  border-bottom">
                <p class="font-weight-bold mb-0 text-secondary">No bills in this note</p>
                @include('app/patient/note/_create-bill')
            </div>
        @endif
        </div>
    @endif

    {{-- generic bills --}}
    @if($pro->pro_type === 'ADMIN' || ($note->allyPro && $pro->id === $note->allyPro->id))
        <div class="screen-only" data-non-segment-section="NA Bills">
            @include('app.generic-bills.inline', ['patient' => $patient, 'note' => $note, 'class' => 'p-3 border-bottom', 'label' => 'NA', 'entityType' => 'Note', 'entityUid' => $note->uid])
        </div>
    @endif

    {{-- invoices --}}
    @if($pro->pro_type === 'ADMIN')
        <div class="screen-only p-3 border-bottom" data-non-segment-section="Invoices">
            @include('app.generic-invoices.index', ['patient' => $patient, 'parentType' => 'Note', 'parentID' => $note->id, 'parentUid' => $note->uid])
        </div>
    @endif

    {{-- claims --}}
    @if($pro->pro_type === 'ADMIN')
        <div class="screen-only" data-non-segment-section="Claims">
        @if($note->claims->count())
            <div class="screen-only p-3">
            <div class="d-flex align-items-center mb-2">
                <p class="font-weight-bold text-secondary m-0">Claims</p>
                @include('app.patient.note.refresh-suggestions-json')
                @include('app/patient/note/_create-claim')
                <div class="ml-auto">
                    <select class="form-control form-control-sm"
                            onchange="fastLoad('{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}?claims-filter=' + this.value)">
                        <option value="active" {{!request('claims-filter') || request('claims-filter') === 'active' ? 'selected' : ''}}>Active Claims</option>
                        <option value="all" {{request('claims-filter') === 'all' ? 'selected' : ''}}>All Claims</option>
                    </select>
                </div>
            </div>

            <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
                <thead class="bg-light">
                <tr>
                    <th class="border-bottom-0 pl-2">IID</th>
                    <th class="border-bottom-0">Details</th>
                    <th class="border-bottom-0">Status</th>
                    <th class="border-bottom-0">Submissions</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($note->claims as $claim)
                    @if($claim->status !== 'CANCELLED' || request('claims-filter') === 'all')
                        <tr class="bg-secondary on-hover-opaque">
                            <td colspan="5" class="pt-0 pb-1"></td>
                        </tr>
                        <tr class="{{ $claim->status === 'CANCELLED' ? 'text-secondary bg-light on-hover-opaque' : '' }}">
                            <td class="pl-2">
                                <div>{{ $claim->iid }}</div>
                                <div class="text-sm text-secondary font-weight-bold mt-1">Current Version:</div>
                                <div class="text-sm text-secondary">{{$claim->currentVersion ? friendlier_date_time($claim->currentVersion->created_at) : '-'}}</div>
                                @if($claim->status === 'CANCELLED')
                                    <div class="text-secondary font-weight-bold text-sm mt-1">[CANCELLED]</div>
                                @else
                                    <div moe class="text-left mt-1" title="Cancel Claim">
                                        <a class="" href="" show start>Cancel</a>
                                        <form url="/api/claim/updateStatus">
                                            <input type="hidden" name="uid" value="{{$claim->uid}}">
                                            <input type="hidden" name="status" value="CANCELLED">
                                            <p>Cancel this claim?</p>
                                            <div class="mb-2">
                                                <label for="" class="control-label">Cancellation Memo</label>
                                                <textarea name="memo" class="form-control"></textarea>
                                            </div>
                                            <div class="mb-0">
                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </div>
                                @endif
                            </td>
                            <td class="p-0 border-left border-right">
                                @if($claim->lines->count())
                                    <table class="table table-sm table-condensed border-0 mb-0">
                                        <thead>
                                            <tr class="bg-light">
                                                <th class="border-0">CPT</th>
                                                <th class="border-0">DOS</th>
                                                <th class="border-0">ICDs</th>
                                            </tr>
                                        </thead>
                                        <tbody class="pb-3">
                                            @foreach($claim->lines as $line)
                                                <tr class="claim-line">
                                                <td>{{$line->cpt}}
                                                    <div>Units: <b>{{!@$line->units ? 1 : $line->units}}</b></div>
                                                </td>
                                                <td class="text-nowrap">{{friendlier_date($line->date_of_service)}}</td>
                                                <td>
                                                    @if(count($line->claimLineIcds))
                                                        @foreach($line->claimLineIcds as $icd)
                                                            <div>
                                                                <b class="c-pointer border-secondary border-bottom" title="{{$icd->description}}">{{$icd->code}}</b>
                                                            </div>
                                                        @endforeach
                                                    @else
                                                        <p>No ICDs set</p>
                                                    @endif
                                                </td>
                                            </tr>
                                            @endforeach
                                        </tbody>
                                    </table>
                                @else
                                    <p>No lines for this claim</p>
                                @endif
                            </td>
                            <td class="border-right p-0">

                                <!-- payer, company, location -->
                                <div class="p-1">
                                    <div class="mt-1">
                                        <div>
                                        <span class="text-secondary text-sm">Payer (1°): </span>
                                        <b>{{$claim->primaryPayer ? $claim->primaryPayer->name : '-'}}</b>
                                        @if(0 && $claim->status !== 'CANCELLED')
                                                <span moe class="ml-1">
                                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                <form url="/api/claim/putPrimaryPayer">
                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                    <div class="mb-2">
                                                        <select name="primaryPayerUid" class="form-control form-control-sm">
                                                            <option value="">-- select --</option>
                                                            @foreach($note->hcpPro->companyProPayers as $companyProPayer)
                                                                <option value="{{$companyProPayer->payer->uid}}"
                                                                        {{$claim->primaryPayer && $claim->primaryPayer->uid === $companyProPayer->payer->uid ? 'selected' : ''}}>{{$companyProPayer->payer->name}}</option>
                                                            @endforeach
                                                        </select>
                                                    </div>
                                                    <div class="mb-0">
                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                                @if($claim->primaryPayer)
                                                    <span moe class="ml-1">
                                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                <form url="/api/claim/wipePrimaryPayer">
                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                    <p>Wipe payer from this claim?</p>
                                                    <div class="mb-0">
                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                                @endif
                                            @endif
                                        </div>
                                        <div class="py-1 border-bottom d-flex align-items-center">
                                            <span class="text-secondary text-sm pr-1">Status: </span>
                                            <div>
                                                {{$claim->status ? $claim->status : '(not set)'}}
                                                @if($claim->status !== 'CANCELLED')
                                                    <span moe class="d-inline-block text-left ml-1" title="Update Status">
                                                        <a class="" href="" show start><i class="fa fa-edit"></i></a>
                                                        <form url="/api/claim/updateStatus">
                                                            <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                            <div class="mb-2">
                                                                <label for="" class="control-label">Status</label>
                                                                <select name="status" class="form-control form-control-sm" required>
                                                                    <option value="">-- select --</option>
                                                                    <option value="NEW" {{$claim->status === 'NEW' ? 'selected' : ''}}>New</option>
                                                                    <option value="PICKED_UP" {{$claim->status === 'PICKED_UP' ? 'selected' : ''}}>Picked Up</option>
                                                                    <option value="SUBMITTED" {{$claim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
                                                                    <option value="IN_PROCESS" {{$claim->status === 'IN_PROCESS' ? 'selected' : ''}}>In Process</option>
                                                                    <option value="ACCEPTED" {{$claim->status === 'ACCEPTED' ? 'selected' : ''}}>Accepted</option>
                                                                    <option value="REJECTED" {{$claim->status === 'REJECTED' ? 'selected' : ''}}>Rejected</option>
                                                                    <option value="ABANDONED" {{$claim->status === 'ABANDONED' ? 'selected' : ''}}>Abandoned</option>
                                                                </select>
                                                            </div>
                                                            <div class="mb-2">
                                                                <label for="" class="control-label">Status Memo</label>
                                                                <textarea name="memo" class="form-control"></textarea>
                                                            </div>
                                                            <div class="mb-0">
                                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                            </div>
                                                        </form>
                                                    </span>
                                                @endif
                                            </div>
                                            @if($claim->status_memo)
                                                <div class="text-secondary font-italic text-sm">{{$claim->status_memo}}</div>
                                            @endif
                                        </div>
                                    </div>

                                    <div class="mt-1">
                                        <span class="text-secondary text-sm">Payer (2°): </span>
                                        <b>-</b>
                                    </div>

                                    <div class="mt-1">
                                        <span class="text-secondary text-sm">Company: </span>
                                        <b>{{$claim->companyPro && $claim->companyPro->company ? $claim->companyPro->company->name : '-'}}</b>
                                        @if(0 && $claim->status !== 'CANCELLED')
                                            <span moe class="ml-1">
                                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                <form url="/api/claim/putCompanyPro">
                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                    <div class="mb-2">
                                                        <select name="companyProUid" class="form-control form-control-sm">
                                                            <option value="">-- select --</option>
                                                            @foreach($note->hcpPro->companyProPayers as $companyProPayer)
                                                                <option value="{{$companyProPayer->companyPro->uid}}"
                                                                        {{$claim->companyPro && $claim->companyPro->uid === $companyProPayer->companyPro->uid ? 'selected' : ''}}>{{$companyProPayer->company->name}}</option>
                                                            @endforeach
                                                        </select>
                                                    </div>
                                                    <div class="mb-0">
                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                            @if($claim->companyPro && $claim->companyPro->company)
                                                <span moe class="ml-1">
                                                    <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                    <form url="/api/claim/wipeCompanyPro">
                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                        <p>Wipe company from this claim?</p>
                                                        <div class="mb-0">
                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                        </div>
                                                    </form>
                                                </span>
                                            @endif
                                        @endif
                                    </div>

                                    <div class="mt-1">
                                        <span class="text-secondary text-sm">Location: </span>
                                        <b>{{$claim->companyLocation ? $claim->companyLocation->line1 . ', ' . $claim->companyLocation->city : '-'}}</b>
                                        @if(0 && $claim->status !== 'CANCELLED')
                                            <span moe class="ml-1">
                                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                <form url="/api/claim/putCompanyLocation">
                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                    <div class="mb-2">
                                                        <select name="companyLocationUid" class="form-control form-control-sm">
                                                            <option value="">-- select --</option>
                                                            @if($claim->company && $claim->company->locations)
                                                                @foreach($claim->company->locations as $location)
                                                                    <option value="{{$location->uid}}"
                                                                            {{$claim->companyLocation && $claim->companyLocation->uid === $location->uid ? 'selected' : ''}}>
                                                                        {{$location->line1 . ', ' . $location->city}}
                                                                    </option>
                                                                @endforeach
                                                            @endif
                                                        </select>
                                                    </div>
                                                    <div class="mb-0">
                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                            @if($claim->companyLocation)
                                                <span moe class="ml-1">
                                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                <form url="/api/claim/wipeCompanyLocation">
                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
                                                    <p>Wipe location from this claim?</p>
                                                    <div class="mb-0">
                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                            @endif
                                        @endif
                                    </div>
                                </div>
                            </td>
                            <td class="p-0 border-left border-right">
                                <table class="table table-sm table-condensed border-0 mb-0">
                                    @if($claim->status !== 'CANCELLED')
                                        <thead>
                                        <tr class="">
                                            <th colspan="3" class="border-top-0 border-bottom">
                                                <div>
                                                    <span moe class="d-block" title="Submit Claim">
                                                        <a class="" href="" show start>Generate Submission to Payer (1°)</a>
                                                        <form url="/api/mbClaim/createFromClaimForPrimaryPayer">
                                                            <input type="hidden" name="claimUid" value="{{$claim->uid}}">
                                                            <p>Generate Submission?</p>
                                                            <div class="mb-0">
                                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                            </div>
                                                        </form>
                                                    </span>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                    @endif
                                    @if(count($claim->mbClaims))
                                        <thead>
                                        <tr class="bg-light">
                                            <th class="border-0">Created</th>
                                            <th class="border-0">Status</th>
                                            <th class="border-0">&nbsp;</th>
                                        </tr>
                                        </thead>
                                        <tbody class="pb-3">
                                        @foreach($claim->mbClaims as $mbClaim)
                                            <tr>
                                                <td>
                                                    @if($mbClaim->claim_version_id !== $claim->current_version_id)
                                                        <i class="fa fa-exclamation-triangle text-warning-mellow text-sm" title="This submission was generated using an older version of the claim"></i>
                                                    @else
                                                        <i class="fa fa-asterisk text-secondary text-sm" title="This submission is up to date"></i>
                                                    @endif
                                                    <a native target="_blank"
                                                       open-in-stag-popup
                                                       title="Submission Details"
                                                       href="{{route('mb-claim', ['patient' => $patient, 'mbClaim' => $mbClaim])}}">
                                                        {{ friendlier_date_time($mbClaim->created_at) }}
                                                    </a>
                                                </td>
                                                <td>
                                                    {{$mbClaim->status}}
                                                    @if($mbClaim->status_memo)
                                                        <div class="font-italic text-secondary text-sm">{{$mbClaim->status_memo}}</div>
                                                    @endif
                                                </td>
                                                <td class="text-right pr-2">
                                                     <span moe relative title="Submit Claim">
                                                        <a class="" href="" show start><i class="fa fa-edit"></i></a>
                                                        <form url="/api/mbClaim/updateStatus" right>
                                                            <input type="hidden" name="uid" value="{{$mbClaim->uid}}">
                                                            <div class="form-group">
                                                                <label for="" class="control-label">Status</label>
                                                                <select name="status" class="form-control form-control-sm" required>
                                                                    <option value="">-- select --</option>
                                                                    <option value="NEW" {{$mbClaim->status === 'NEW' ? 'selected' : ''}}>New</option>
                                                                    <option value="PROCESSING" {{$mbClaim->status === 'PROCESSING' ? 'selected' : ''}}>Processing</option>
                                                                    <option value="SUBMITTED" {{$mbClaim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
                                                                    <option value="CANCELLED" {{$mbClaim->status === 'CANCELLED' ? 'selected' : ''}}>Cancelled</option>
                                                                </select>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="" class="control-label">Status Memo</label>
                                                                <textarea name="memo" class="form-control"></textarea>
                                                            </div>
                                                            <div class="mb-0">
                                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                            </div>
                                                        </form>
                                                    </span>
                                                    <a class="ml-1" target="_blank" native href="/api/mbClaim/downloadEDI/{{$mbClaim->uid}}" show start><i class="fa fa-file-download"></i></a>
                                                    <a class="ml-1 text-success" href="" show start><i class="fa fa-arrow-right"></i></a>
                                                </td>
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    @else
                                        <tbody>
                                            <tr>
                                                <td colspan="3">
                                                    <p class="p-1 text-secondary m-0">No submissions in this claim</p>
                                                </td>
                                            </tr>
                                        </tbody>
                                    @endif
                                </table>
                            </td>
                        </tr>
                    @endif
                @endforeach
                </tbody>
            </table>
        </div>
        @else
            <div class="screen-only p-3 d-flex">
            <p class="font-weight-bold mb-0 text-secondary">No claims in this note</p>
            @include('app.patient.note.refresh-suggestions-json')
            @include('app/patient/note/_create-claim')
        </div>
        @endif
        </div>
    @endif
    </div>