<div class="d-flex align-items-baseline">
    <?php
    $coverage = $patient->getPrimaryCoverage();
    $coverageStatus = $patient->getPrimaryCoverageStatus();
    ?>

    @if($coverageStatus === 'YES')
        <i class="fa fa-check-circle text-success"></i>
    @elseif($coverageStatus === 'NO')
        @if($coverage && !$coverage->manual_determination_category)
            <i class="fas fa-hourglass-half text-warning" title="Pending Validation"></i>
        @else
            <i class="fa fa-times text-danger"></i>
        @endif
    @else
        @if($coverage && $coverage->plan_type == 'MEDICARE' && !$coverage->auto_medicare_is_match_found)
            <i class="fa fa-times text-danger"></i>
        @elseif($coverage && $coverage->plan_type == 'MEDICAID' && !$coverage->auto_medicaid_is_match_found)
            <i class="fa fa-times text-danger"></i>
        @elseif($coverage && $coverage->plan_type == 'COMMERCIAL' && !$coverage->auto_commercial_is_match_found)
            <i class="fa fa-times text-danger"></i>
        @else
            <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
        @endif
    @endif

    <div class="ml-2 d-inline-flex align-items-baseline">
        @if($coverage)
            @if($coverage->plan_type === 'MEDICAID' && $coverage->mcdPayer)
                <span class="{{ @$truncateName ? 'coverage-payer-name':'' }}"
                      title="{{$coverage->mcdPayer->name}}">{{$coverage->mcdPayer->name}}</span>
            @elseif($coverage->plan_type === 'COMMERCIAL' && $coverage->payer)
                <span class="{{ @$truncateName ? 'coverage-payer-name':'' }}"
                      title="{{$coverage->payer->name}}">{{$coverage->payer->name}}</span>
            @else
                <span class="{{ @$truncateName ? 'coverage-payer-name':'' }}"
                      title="{{$coverage->insuranceDisplayName()}}">{{$coverage->insuranceDisplayName()}}</span>
            @endif
        @else
            <small class="ml-2 text-muted">(No insurance)</small>
        @endif
        <div class="">
            @if($coverage && $coverage->plan_type === 'MEDICARE')
                @if(@$patient->mpb_remaining)
                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
                @endif
            @endif
            @if($coverage && $coverage->plan_type === 'COMMERCIAL')
                @if(@$coverage->deductible_amount && !!+@$coverage->deductible_amount)
                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$coverage->deductible_amount)}})</span>
                @endif
            @endif
        </div>
    </div>
</div>
