<style>
    .tableDetail {
        width: 100%;
        border-collapse: collapse;
        padding: 3px;
    }

    .tdDetail {
        border-bottom: 0.5px dotted gray;
        padding: 8px;
    }
</style>

<table style="width: 100%; font-size: 8pt;">
    <tr>
        <td style="width: 15%;">
            <div>
                <img src="<?= base_url('images/pinna_hospital.jpg'); ?>" style="width: 70px;">
            </div>
        </td>
        <td style="width: 85%;">
            <h3>
                <?= $utama->NamaPerusahaan; ?>
            </h3> <br>
            <?= $utama->AlamatPerusahaan; ?><br>
            Telp: <?= $utama->TeleponPerusahaan; ?><br>
            Fax: <?= $utama->FaxPerusahaan; ?><br>
        </td>
    </tr>
</table>

<table style="width: 100%; font-size: 8pt;">
    <tr>
        <td style="width: 50%;">
            <table style="width: 100%;">
                <tr>
                    <td style="width: 35%;">No.Lab</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->LabNo; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Nama</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->PatientName; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Tanggal Lahir</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= date('d F Y', strtotime($header->TanggalLahir)); ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Dokter</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->FirstName; ?></td>
                </tr>
                <!-- <tr>
                    <td style="width: 35%;">Ruangan</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->Ruangan; ?></td>
                </tr> -->
                <tr>
                    <td style="width: 35%;">Tanggal Hasil</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= date('d F Y', strtotime($header->SampleDate)); ?> <?= date('H:i', strtotime($header->SampleTime)); ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Dokter Spk</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->dokterSpk; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Alamat Pasien</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->Address; ?></td>
                </tr>
            </table>
        </td>
        <td style="width: 50%;">
            <table style="width: 100%; font-size: 8pt;">
                <tr>
                    <td style="width: 35%;">No.Registrasi</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->MR; ?> / <?= $header->caseid; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Tanggal Kunjungan</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= date('d F Y', strtotime($header->tanggalKunjungan)); ?> <?= date('H:i', strtotime($header->jamKunjungan)); ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Umur</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->Age; ?> Th <?= $header->UsiaKunjungan_bulan; ?> Bln <?= $header->UsiaKunjungan_hari; ?> Hr</td>
                </tr>
                <?php
                if ($header->Sex == 2) {
                    $jk = 'Laki-laki';
                } else {
                    $jk = 'Perempuan';
                }
                ?>
                <tr>
                    <td style="width: 35%;">Jenis Kelamin</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $jk; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Penjamin</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= $header->Penjamin; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Tanggal Permintaan</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= date('d F Y', strtotime($header->ReceiptDate)); ?> <?= $header->ReceiptTime; ?></td>
                </tr>
                <tr>
                    <td style="width: 35%;">Tanggal Cetak</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= date('d F Y', strtotime($header->TanggalCetak)); ?> <?= date('H:i', strtotime($header->SampleTime)); ?></td>
                </tr>
                <!-- <tr>
                   <?php
                    $id = $header->caseid;
                    $diag = $this->db->query("Select * From erm_diagnosaMedis where kategori='Diagnosa Utama' and caseid = '$id'")->row();
                    ?>

                    <td style="width: 35%;">Diagnosa</td>
                    <td style="width: 5%;">:</td>
                    <td style="width: 60%;"><?= @$header->Diagnosa; ?> <?= @$diag->deskripsi_icd; ?> <?= @$diag->deskripsi_teks; ?></td>
                </tr> -->
            </table>
        </td>
    </tr>
</table>
<br>
<hr>
<br>
<div style="text-align: center;">
    <h3>HASIL PEMERIKSAAN LABORATORIUM</h3>
</div>
<br>

<table style="width: 100%; background-color: #ededed; font-size: 8pt;" class="tableDetail">
    <tr style="font-weight: bold;">
        <td class="tdDetail" style="width: 153px;">Pemeriksaan<br>(Bahasa)</td>
        <td class="tdDetail" style="width: 127px;">Pemeriksaan<br>(English)</td>
        <td class="tdDetail" style="width: 100px;">Hasil<br>Pemeriksaan</td>
        <td class="tdDetail" style="width: 78px;">Satuan</td>
        <td class="tdDetail" style="width: 77px;">Nilai Normal</td>
    </tr>
</table>
<br><br>
<table style="width: 100%; font-size: 8pt;">
    <?php
    foreach ($kategoriLab as $kategori):
        $idKategori = $kategori->CategoryID;
    ?>
        <tr>
            <td colspan="2" style="width: 100%;"><b><?= $kategori->Category; ?></b><br></td>
        </tr>
        <tr>
            <td style="width: 3%;"></td>
            <td style="width: 97%;">
                <?php
                $detail = $this->db->query("SELECT d.*, r.Unit FROM tblLabResultDetail d LEFT JOIN tblLabReference r ON d.ResultID=r.ResultID WHERE LabNo = '$noLab' AND d.CategoryID = '$idKategori'")->result();
                ?>
                <table style="width: 100%;" class="tableDetail">
                    <?php
                    foreach ($detail as $tindakan):
                        if ($tindakan->ColorValue == 'red') {
                            $color = 'style="color: red;"';
                        } else {
                            $color = '';
                        }
                    ?>
                        <tr>
                            <td class="tdDetail" style="width: 25%;"><span <?= $color; ?>><?= $tindakan->Bahasa; ?></span></td>
                            <td class="tdDetail" style="width: 25%;"><span <?= $color; ?>><?= $tindakan->English; ?></span></td>
                            <td class="tdDetail" style="width: 20%;"><span <?= $color; ?>><?= $tindakan->ResultValue; ?></span></td>
                            <td class="tdDetail" style="width: 15%;"><?= $tindakan->Unit; ?></td>
                            <td class="tdDetail" style="width: 15%;"><?= $tindakan->NormalValue; ?></td>
                        </tr>

                    <?php
                    endforeach;
                    ?>
                </table>
                <br>
            </td>
        </tr>
    <?php
    endforeach;
    ?>
</table>

<br><br><br>
<table align="right" style="width: 100%; font-size: 8pt;">
    <tr>
        <td style="width: 70%;"></td>
        <td style="width: 30%; text-align: center;">Bekasi, <?= date('d F Y', strtotime($header->TanggalCetak)); ?></td>
    </tr>
    <!-- <tr>
        <td style="width: 70%;"></td>
        <td style="width: 30%; text-align: center;"><br><br><br><br><br></td>
    </tr> -->
    <tr>
        <td style="width: 70%;"></td>
        <!-- <td style="width: 30%; text-align: center;">( <?= $header->dokterSpk; ?> )</td> -->
        <td style="width: 30%; text-align: center;"><img style="width: 60px;" src="<?= base_url('images/uploadsign/dokter/' . $header->DoctorLab); ?>.png"> <br> ( <?= $header->dokterSpk; ?> )</td>
    </tr>
</table>