@extends('operations.layout.mainlayout') @section('content') @php $selectedHospitalIds = $insurance ? $insurance->hospitals->pluck('ID')->toArray() : []; $selectedCityId = $insurance ? $insurance->CITY_ID : null; $syncStatus = $insurance && $insurance->SYNC_STATUS ? $insurance->SYNC_STATUS : 'PENDING'; $contractStatusClass = $contractInfo['status'] == 'ACTIVE' ? 'status-active' : ($contractInfo['status'] == 'EXPIRED' ? 'status-expired' : 'status-pending'); $syncStatusClass = $syncStatus == 'SUCCESS' ? 'status-active' : ($syncStatus == 'FAILED' ? 'status-failed' : 'status-pending'); $denialRateClass = $claimSummary['denial_rate'] < 3 ? 'rate-low' : ($claimSummary['denial_rate'] <= 6 ? 'rate-mid' : 'rate-high'); $denialRateLabel = $claimSummary['denial_rate'] > 6 ? 'Above Avg' : 'Normal'; $denialRateWidth = min(100, max(0, $claimSummary['denial_rate'])); @endphp

{{ $insurance ? 'Edit Insurance Provider' : 'Add Insurance Provider' }}

{{ $insurance ? $insurance->NAME : 'Create a provider profile with coverage plans and local sync status' }}

Cancel
@if($insurance)
Contract Status {{ $contractInfo['status'] }}
Days Until Expiry {{ $contractInfo['days_until_expiry'] === null ? '-' : $contractInfo['days_until_expiry'] }}
Denial Rate {{ number_format($claimSummary['denial_rate'], 2) }}%
{{ $denialRateLabel }}
Active Claims {{ $claimSummary['active_total'] }}
Open: {{ $claimSummary['open'] }} Pending: {{ $claimSummary['pending'] }} Under Review: {{ $claimSummary['under_review'] }}
@endif

General Information

Contact & Integration

IS_ACTIVE == 1 ? 'checked' : '' }}>
IS_BLOCKED == 1 ? 'checked' : '' }}>
SEND_INVOICE == 1 ? 'checked' : '' }}>

Billing Information

SAR
%

Contract Details

AUTO_RENEWAL_ENABLED == 1 ? 'checked' : '' }}>
@if($insurance)

Coverage Plans

@php $totalPlans = $insurance->coveragePolicies->count(); $fullCoveragePlans = $insurance->coveragePolicies->filter(function ($policy) { return (float)$policy->DEDUCTIBLE_AMOUNT == 0; })->count(); $approvalPlans = $insurance->coveragePolicies->filter(function ($policy) { return $policy->APPROVAL_REQUIRED == 1; })->count(); $networkTypeCount = $insurance->coveragePolicies->filter(function ($policy) { return !empty($policy->NETWORK_TYPE_ID); })->pluck('NETWORK_TYPE_ID')->unique()->count(); @endphp
Total Plans{{ $totalPlans }}
Full Coverage{{ $fullCoveragePlans }}
Approval Required{{ $approvalPlans }}
Network Types{{ $networkTypeCount }}
@forelse($insurance->coveragePolicies as $policy) @php $policyCoverageTypes = $policy->COVERAGE_TYPES ?: []; $policyCoverageTypes = is_array($policyCoverageTypes) ? $policyCoverageTypes : json_decode($policyCoverageTypes, true); $policyCoverageTypes = is_array($policyCoverageTypes) ? $policyCoverageTypes : []; @endphp

{{ $policy->POLICY_NAME }}

{{ $policy->POLICY_NAME_AR }}
@if($policy->APPROVAL_REQUIRED) Approval Required @else No Approval @endif
@foreach($policyCoverageTypes as $policyCoverageType) {{ $policyCoverageType }} @endforeach
Coverage LimitSAR {{ number_format((float)$policy->COVERAGE_LIMIT, 2) }}
Co-payment{{ number_format((float)$policy->COPAY_PERCENTAGE, 2) }}%
DeductibleSAR {{ number_format((float)$policy->DEDUCTIBLE_AMOUNT, 2) }}
Network{{ optional($policy->networkType)->NAME ?: '-' }}
@empty
No coverage plans added yet.
@endforelse
@else
Save the provider first to add coverage plans.
@endif
@if($insurance)

Documents

@if($insurance->documents->count())
@foreach($insurance->documents as $document) @php $ext = strtolower(pathinfo($document->FILE_PATH ?? '', PATHINFO_EXTENSION)); $icon = in_array($ext, ['pdf']) ? 'fa-file-pdf' : (in_array($ext, ['doc','docx']) ? 'fa-file-word' : (in_array($ext, ['xls','xlsx']) ? 'fa-file-excel' : (in_array($ext, ['jpg','jpeg','png','gif']) ? 'fa-file-image' : 'fa-file-alt'))); @endphp
{{ $document->DOCUMENT_NAME }} {{ $document->DOCUMENT_TYPE }} ยท {{ \Carbon\Carbon::parse($document->created_at)->format('M d, Y') }}
@endforeach
@else
No documents uploaded yet
@endif
@else
Save the provider first to upload documents.
@endif
@if($insurance)

Synchronization Status

{{ $insurance && $insurance->LAST_SYNC_AT ? $insurance->LAST_SYNC_AT : '-' }}
{{ $syncStatus }}
{{ $insurance ? (int)$insurance->RECORDS_SYNCED : 0 }}
{{ $insurance && $insurance->NEXT_SYNC_AT ? $insurance->NEXT_SYNC_AT : '-' }}
{{ $insurance && $insurance->SYNC_SOURCE ? $insurance->SYNC_SOURCE : '-' }}
{{ $insurance && $insurance->PREVIOUS_SYNC_STATUS ? $insurance->PREVIOUS_SYNC_STATUS : '-' }}
@else
Save the provider first to manage synchronization.
@endif
@if($insurance)

Renewal History

@forelse($renewals as $renewal) @empty @endforelse
Renewal No. From To Duration Status
{{ $renewal->RENEWAL_NO }} {{ $renewal->CONTRACT_START_DATE ?: '-' }} {{ $renewal->CONTRACT_END_DATE ?: '-' }} {{ $renewal->DURATION_DAYS === null ? '-' : $renewal->DURATION_DAYS . ' days' }} {{ $renewal->STATUS ?: '-' }}
No renewal history yet
@else
Save the provider first to view renewal history.
@endif
@endsection @section('footer-scripts') @endsection