<?php
use App\Helpers\Helper;
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Surat Jaminan Akhir - {{ $claim->code }}</title>

    {{-- <link rel="stylesheet" href="{{ public_path('css/app.css') }}"> --}}
    
    {{-- @vite('resources/css/app.css') --}}
    {{----}}
    <?php ob_start(); ?>
    @vite('resources/css/app.css')
    <?php 
        $viteString = ob_get_contents();
        $publicPath = str_replace(env('APP_URL'),"/var/www/aso/public",$viteString);

        echo $publicPath;
        ob_end_clean();
    ?>
    {{----}}
    {{-- <link rel="stylesheet" href="/var/www/html/aso/public/build/assets/app-179954eb.css"> --}}

    <style>
        /* @font-face {
            font-family: Public Sans;
            src: url('{{asset('fonts/PublicSans-Medium.ttf')}}');
            src: url('{{asset('fonts/PublicSans-Medium.ttf')}}') format('truetype');
        } */
        @page {
            size: A4;
            margin: 0;
        }
        
        html, body {
            width: 210mm;
            height: 297mm;
            font-size: 12px !important;
        }
        @media print {
            html, body {
                width: 210mm;
                height: 297mm;
            }
        /* ... the rest of the rules ... */
        }

        body {
            font-family: 'Public Sans';
            color: #404040;
            font-size: 20px;
        }

        td {
            padding: 3px;
            vertical-align: top;
        }

        #member-detail{
            
        }
        #member-detail td {
            width: 50%;
            padding: 10px 0px;
        }
        #member-detail td>div{
            margin-bottom: 5px;
        }

        .benefit-table-wrapper {
            border: 1px solid #E0E0E0;
            border-radius: 5px;
            overflow: hidden;
        }
        #benefit-table {
            width: 100%;
            border-collapse: collapse;
        }

        #benefit-table th, #benefit-table th {
            width: 50%;
        }

        #benefit-table th{
            font-size: 20px;
            font-weight: 400;
            padding: 15px;
            text-align: left;
        }

        #benefit-table tr:first-child {
            background: #F5F5F5;
            border-bottom: 1px solid #E0E0E0;
        }

        #benefit-table td {
            padding: 15px;
            font-size: 20px;
        }
    </style>
</head>
<body>
    <table style="width: 100%">
        <tr><td colspan="99" style="text-align: center">SURAT JAMINAN AKHIR</td></tr>
        <tr>
            <td style="width: 25%">Kepada</td>
            <td style="width: 25%">: {{ $hospital->name }}</td>
            
            <td style="width: 25%">GOP Tanggal</td>
            <td style="width: 25%">: {{ $claim->created_at->format('d-M-y, H:i') }}</td>
        </tr>
        <tr>
            <td>Alamat</td>
            <td>: {{ $hospital->currentAddress->text ?? '' }}</td>
            
            <td style="width: 25%">GOP Nomor</td>
            <td style="width: 25%">: {{ $claim->code }}</td>
        </tr>
        <tr>
            <td>No Telpon / Fax</td>
            <td>: </td>
        </tr>
        <tr>
            <td>Email</td>
            <td>: </td>
        </tr>
    </table>

    <p>Dengan ini jaminan diberikan kepada pasien yang juga meruopakan tertanggung/peserta yang diasuransikan "Pasien" dengan data sebagai berikut</p>


    <table style="width: 100%">
        <tr><td colspan="99" style="background: red; padding-left: 30px; color: white">A. Identitas Pasien</td></tr>
        <tr>
            <td style="width: 25%">1. Nama Pasien</td>
            <td style="width: 25%">: {{ $member->full_name }}</td>
            
            <td style="width: 25%">7. Hak Kelas Kamar</td>
            <td style="width: 25%">: {{ $inpatienBenefit->room_class_coverage ?? '' }}</td>
        </tr>
        <tr>
            <td>2. Tanggal Lahir</td>
            <td>: {{ $member->birth_date ?? '' }}</td>

            <td>8. Hak Kamar ICU</td>
            <td>: </td>
        </tr>
        <tr>
            <td>3. Jenis Kelamin</td>
            <td>: {{ ($member->gender ? 
                ($member->gender == 'female' ? 'Perempuan' 
                    : ($member->gender == 'male' ? 'Laki-Laki' 
                        : $member->gender) 
                ) : '') }}</td>
            
            <td>9. No Polis</td>
            <td>: {{ $member->currentPolicy?->code ?? '' }}</td>
        </tr>
        <tr>
            <td>4. Nomor e-KTP</td>
            <td>: {{ $member->nric }}</td>
            
            <td>10. Nama PH / Perusahaan</td>
            <td>: {{ $member->currentCorporate?->name ?? '' }}</td>
        </tr>
        <tr>
            <td>5. Manfaat</td>
            <td>: {{ $claim->claimRequest?->service?->name ?? '' }}</td>
            
            <td>11. Periode Polis</td>
            <td>: {{ $member->currentPolicy ? \Carbon\Carbon::parse($member->currentPolicy->end)->format('d-M-Y') : '' }}</td>
        </tr>
        <tr>
            <td>6. Status Polis</td>
            <td>: {{ $member->currentPolicy?->status ?? '' }}</td>
            
            <td>12. Mata Uang</td>
            <td>: {{ $member->currency ?? 'IDR' }}</td>
        </tr>

        <tr><td colspan="99" style="background: red; padding-left: 30px; color: white">B. Informasi Perawatan</td></tr>
        <tr>
            <td style="width: 25%">1. Tanggal Masuk</td>
            <td style="width: 25%">: {{ $claim->finalEncounter->start ?? "" }}</td>
            
            <td style="width: 25%">7. Lama Perawatan</td>
            <td style="width: 25%">: {{ $claim->finalEncounter->duration_day ?? "" }}</td>
        </tr>
        <tr>
            <td>2. Tanggal Keluar</td>
            <td>: {{ $claim->finalEncounter->end }}</td>

            <td>8. Kamar Perawatan</td>
            <td>: {{ "" }}</td>
        </tr>
        <tr>
            <td>3. Nama Rumah Sakit</td>
            <td>: {{ $hospital->name }}</td>
            
            <td>9. Jumlah Tempat Tidur</td>
            <td>: {{ $claim->finalEncounter->number_of_bed }}</td>
        </tr>
        <tr>
            <td>4. Dokter yang Merawat</td>
            <td>: {{ $claim->finalEncounter->doctors->first()->person->name ?? '' }}</td>
            
            <td>10. Estimasi Biaya Rawat Inap</td>
            <td>: {{ $claim->total_tagihan ? Helper::currencyIdrFormat($claim->total_tagihan) : "" }}</td>
        </tr>
        <tr>
            <td>5. No. Rekam Medis</td>
            <td>: {{ $claim->finalEncounter->meta->MEDRECID }}</td>
            
            <td>11. Diagnosa</td>
            <td>: {{ $claim->diagnosis?->icd?->code ?? '' }}/{{ $claim->diagnosis?->icd?->name ?? '' }}</td>
        </tr>

        
        <tr><td colspan="99" style="background: red; padding-left: 30px; color: white">C. Nilai Jaminan</td></tr>
        <tr>
            <td colspan="99">
                <table style="width: 100%">
                    <tr>
                        <th>Manfaat Polis</th>
                        <th>Biaya Diajukan</th>
                        <th>Biaya Dijamin</th>
                        <th>Biaya Tidak Dijamin</th>
                    </tr>
                    @foreach ($claim->items as $item)    
                    <tr>
                        <td style="text-align:left">{{ $item->claim_itemable->description }}</td>
                        <td style="text-align:center">{{ Helper::currencyIdrFormat($item->nominal_ditagihkan)}}</td>
                        <td style="text-align:center">{{ Helper::currencyIdrFormat($item->nominal_dicover) }}</td>
                        <td style="text-align:center">{{ Helper::currencyIdrFormat($item->nominal_ditagihkan - $item->nominal_dicover) }}</td>
                    </tr>
                    @endforeach
                </table>

                <p>Tidak Dijamin : Full Cover</p>
                <p>* Bila pasien menempati kamar perawatan di atas manfaat yang imiliki maka pasien wajib membayar selisih yang timbul dan biaya yang tidak dijamin setelah menjalani perawatan Rumah Sakit</p>
            </td>
        </tr>

        
        <tr><td colspan="99" style="background: red; padding-left: 30px; color: white">D. Otorisasi Surat Jaminan</td></tr>
        <tr><td colspan="99">Surat Jaminan ini diotorisasi oleh PMN</td></tr>

        <tr>
            <td colspan="99">
                <table style="width: 100%;">
                    <tr>
                        <td style="max-width: {{1/3}}%; overflow: visible; text-align: center">
                            Hormat Kami
                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            (PRUMedical Network)
                        </td>
                        <td style="max-width: {{1/3}}%; overflow: visible; text-align: center">
                            Staff Administrasi Rumah Sakit
                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            (&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)
                        </td>
                        <td style="max-width: {{1/3}}%; overflow: visible; text-align: center">
                            PH/Pasien/Keluarga
                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            ({{ $member->full_name }})
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>



    <div>
        <p><strong>*) Surat ini tidak memerlukan tanda tangan karena dicetak secara komputerisasi</strong></p>
    </div>

    <div style="width: 100%; text-align: right; font-size: 10px; color: #777; margin-top: 20px;"><span style="padding: 15px;">Generated by Primecenter Linksehat at {{ now() }}</span></div>
</body>
</html>