<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ $periksa->nmpasien }} ({{ $periksa->noregister }} - {{ $periksa->nofoto }})</title>

</head>
<body>
    @php 
        $data               = [];
        $data['keterangan'] = $periksa->keterangan;
        if (!empty($komponens)) {
            foreach ($komponens as $rows) {
                $key = trim($rows->komponen);
                if (!empty($key)) {
                    if ($key == 'keterangan') {
                    } else {
                        $data[$key] = $rows->isidata;
                    }
                }
            }
        }
    @endphp
    <table cellpadding="0" cellspacing="0" width="800" border="0">
        @if ($kopsurat == '')
            <tr>
                <td width="45" height="200">&nbsp;</td>
                <td width="173" valign="top">&nbsp;</td>
                <td width="12" valign="top">&nbsp;</td>
                <td width="165" valign="top">&nbsp;</td>
                <td width="115" valign="top">&nbsp;</td>
                <td width="12" valign="top">&nbsp;</td>
                <td width="128" valign="top">&nbsp;</td>
                <td width="254" valign="top">&nbsp;</td>
            </tr>
        @else 
            <tr>
                <td colspan="8"><img src="{!! $kopsurat !!}" width="100%" /></td>
            </tr>
        @endif
        <tr>
            <td colspan="8" align="center"><p><strong><u>HASIL PEMERIKSAAN MIKROBIOLOGI KLINIK</u></strong></p></td>
        </tr>
        <tr>
            <td valign="top" width="45">&nbsp;</td>
            <td valign="top" width="173">No. Laboratorium</td>
            <td valign="top" width="12">:</td>
            <td valign="top" width="165">{{ $periksa->nofoto }}</td>
            <td valign="top" width="115">Tanggal MRS</td>
            <td valign="top" width="12">:</td>
            <td valign="top" colspan="2">{!! $periksa->mulai !!}</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td valign="top">Nama Pasien</td>
            <td valign="top">:</td>
            <td valign="top">{{ $periksa->nmpasien }}</td>
            <td valign="top">Ruang Pengirim</td>
            <td valign="top">:</td>
            <td valign="top" colspan="2">{!! $periksa->asalpasien !!}</td>
        </tr>
        <tr>
            <td valign="top">&nbsp;</td>
            <td valign="top">Jenis Kelamin</td>
            <td valign="top">:</td>
            <td valign="top">{{ $periksa->jkpasien }}</td>
            <td valign="top">Diagnosa</td>
            <td valign="top">:</td>
            <td valign="top" colspan="2">{!! $periksa->klinis !!}</td>
        </tr>

        <tr>
            <td valign="top">&nbsp;</td>
            <td valign="top">Usia</td>
            <td valign="top">:</td>
            <td valign="top">{{ $periksa->usia }}</td>
            <td valign="top">Jenis Pemeriksaan</td>
            <td valign="top">:</td>
            <td valign="top" colspan="2">{!! $periksa->reques !!}</td>
        </tr>

        <tr>
            <td valign="top">&nbsp;</td>
            <td valign="top">Tanggal Kirim Sample</td>
            <td valign="top">:</td>
            <td valign="top">{{ $periksa->daftar }}</td>
            <td valign="top">&nbsp;</td>
            <td valign="top">&nbsp;</td>
            <td valign="top" colspan="2">&nbsp;</td>
        </tr>

        <tr>
            <td valign="top">&nbsp;</td>
            <td valign="top">Tanggal Selesai Hasil</td>
            <td valign="top">:</td>
            <td valign="top">{{ $periksa->verifikasi }}</td>
            <td valign="top">&nbsp;</td>
            <td valign="top">&nbsp;</td>
            <td valign="top" colspan="2">&nbsp;</td>
        </tr>
        <tr><td colspan="8">&nbsp;</td></tr>
        <tr>
            <td width="45">&nbsp;</td>
            <td valign="top" colspan="7" width="755">
                @php 
                $nomor = 1;
                @endphp
                <table style="width:100%">
                    <tr><td valign="top" colspan="3">1. Pewarnaan Gram :</td></tr>
                    @if (isset($data['id_selepitel'])) 
                        <tr>
                            <td valign="top" style="width:20%">Sel epithel</td>
                            <td valign="top" style="width:5%">:</td>
                            <td valign="top" style="width:75%">{!! $data['id_selepitel'] !!}</td>
                        </tr>
                    @endif
                    @if (isset($data['id_selradang'])) 
                        <tr>
                            <td valign="top" style="width:20%">Sel radang</td>
                            <td valign="top" style="width:5%">:</td>
                            <td valign="top" style="width:75%">{!! $data['id_selradang'] !!}</td>
                        </tr>
                    @endif
                    @if (isset($data['id_mikroorganisme']) OR isset($data['id_mikroorganismeoptional'])) 
                        <tr>
                            <td valign="top">Mikroorganisme</td>
                            <td valign="top">:</td>
                            <td valign="top">
                                @if (isset($data['id_mikroorganisme']))
                                    {!! $data['id_mikroorganisme'] !!} 
                                @endif
                                @if (isset($data['id_mikroorganismeoptional']))
                                    <br />{!! $data['id_mikroorganismeoptional'] !!} 
                                @endif
                            </td>
                        </tr>
                    @endif
                    @if (isset($data['id_jumlahlactobacillus']) OR isset($data['id_jumlahgardnerella']) OR isset($data['id_jumlahmobiluncus']))
                        <tr>
                            <td valign="top">&nbsp;</td>
                            <td valign="top" colspan="2">
                                <table cellpadding="0" cellspacing="0" width="100%" border="1">
                                    <tr>
                                        <td width="30%" align="center"><strong>NUGGENT SCORE</strong></td>
                                        <td width="40%" align="center"><strong>Jumlah per lapang pandang besar</strong></td>
                                        <td width="30%" align="center"><strong>skor</strong></td>
                                    </tr>
                                    <tr>
                                        <td>Lactobacillus</td>
                                        <td align="center">
                                            @if (isset($data['id_jumlahlactobacillus']))
                                                {!! $data['id_jumlahlactobacillus'] !!} 
                                            @endif
                                        </td>
                                        <td align="center">
                                            @if (isset($data['id_lactobacillus']))
                                                {!! $data['id_lactobacillus'] !!} 
                                                @php $id_lactobacillus = $data['id_lactobacillus']; @endphp
                                            @else 
                                                @php $id_lactobacillus = 0; @endphp
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Gardnerella</td>
                                        <td align="center">
                                            @if (isset($data['id_jumlahgardnerella']))
                                                {!! $data['id_jumlahgardnerella'] !!} 
                                            @endif
                                        </td>
                                        <td align="center">
                                            @if (isset($data['id_gardnerella']))
                                                {!! $data['id_gardnerella'] !!} 
                                                @php $id_gardnerella = $data['id_gardnerella']; @endphp
                                            @else 
                                                @php $id_gardnerella = 0; @endphp
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Mobiluncus</td>
                                        <td align="center">
                                            @if (isset($data['id_jumlahmobiluncus']))
                                                {!! $data['id_jumlahmobiluncus'] !!} 
                                            @endif
                                        </td>
                                        <td align="center">
                                            @if (isset($data['id_mobiluncus']))
                                                {!! $data['id_mobiluncus'] !!} 
                                                @php $id_mobiluncus = $data['id_mobiluncus']; @endphp
                                            @else 
                                                @php $id_mobiluncus = 0; @endphp
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Total Score</td>
                                        <td>&nbsp;</td>
                                        <td align="center">
                                            @php 
                                                $jumlah = (int)$id_lactobacillus + (int)$id_gardnerella + (int)$id_mobiluncus;
                                                echo $jumlah;
                                                if ($jumlah >= 10){
                                                    $keterangan = "Bacterial vaginosis";
                                                } else if ($jumlah >= 6){
                                                    $keterangan = "Intermediate";
                                                } else {
                                                    $keterangan = "Normal";
                                                }
                                            @endphp
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">KET : {{$keterangan}}</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    @endif
                    <tr><td colspan="3">&nbsp;</td></tr>
                    @if (isset($data['id_pewarnaanziehlnielsen']))
                        @php 
                            $nomor++;
                        @endphp
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan Ziehl Neelsen</td>
                        <td valign="top">:</td>
                        <td valign="top">{!! $data['id_pewarnaanziehlnielsen'] !!}</td>
                    </tr>
                    @endif
                    @if (isset($data['id_pewarnaankoh']))
                        @php 
                            $nomor++;
                        @endphp
                    <tr><td colspan="3">&nbsp;</td></tr>
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan KOH</td>
                        <td valign="top">:</td>
                        <td valign="top">{!! $data['id_pewarnaankoh'] !!}</td>
                    </tr>
                    @endif
                    @if (isset($data['id_pewarnaanneisser']))
                        @php 
                            $nomor++;
                        @endphp
                    <tr><td colspan="3">&nbsp;</td></tr>
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan Neelsen</td>
                        <td valign="top">:</td>
                        <td valign="top">{!! $data['id_pewarnaanneisser'] !!}</td>
                    </tr>
                    @endif
                    @if (isset($data['id_pewarnaannegatif']))
                        @php 
                            $nomor++;
                        @endphp
                    <tr><td colspan="3">&nbsp;</td></tr>
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan Negatif</td>
                        <td valign="top">:</td>
                        <td valign="top">{!! $data['id_pewarnaannegatif'] !!}</td>
                    </tr>
                    @endif
                    @if (isset($data['id_pewarnaanspora']))
                        @php 
                            $nomor++;
                        @endphp
                    <tr><td colspan="3">&nbsp;</td></tr>
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan Spora</td>
                        <td valign="top">:</td>
                        <td valign="top">{!! $data['id_pewarnaanspora'] !!}</td>
                    </tr>
                    @endif
                    @if (isset($data['id_pewarnaangiesma']) OR isset($data['id_pewarnaangiesmaoptional']) )
                        @php 
                            $nomor++;
                        @endphp
                    <tr><td colspan="3">&nbsp;</td></tr>
                    <tr>
                        <td valign="top">{{$nomor}}. Pewarnaan Giemsa</td>
                        <td valign="top">:</td>
                        <td valign="top">
                            @if (isset($data['id_pewarnaangiesma'])) 
                                {!! $data['id_pewarnaangiesma'] !!} 
                            @endif
                            @if (isset($data['id_pewarnaangiesmaoptional'])) 
                                <br />{!! $data['id_pewarnaangiesmaoptional'] !!} 
                            @endif
                        </td>
                    </tr>
                    @endif
                    <tr><td colspan="3">&nbsp;</td></tr>
                    @php
                        $nomor++;
                    @endphp
                    @if (isset($data['id_bakteri01']) OR isset($data['id_bakteri02']))
                        <tr>
                            <td valign="top">{{$nomor}}. Biakan Kultur (Aerob / Anaerob)</td>
                            <td valign="top">:</td>
                            <td valign="top">
                                @if (isset($data['id_biakankultur']))
                                    {!! $data['id_biakankultur'] !!} 
                                @endif
                                <table cellpadding="0" cellspacing="0" width="100%" border="0">
                                    <tr>
                                        <td width="20%">Bakteri I</td>
                                        <td width="5%">:</td>
                                        <td width="75%">
                                            @if (isset($data['id_bakteri01']))
                                                <i>{!! $data['id_bakteri01'] !!}</i>
                                            @endif
                                            @if (isset($data['id_bakterisir01']))
                                                ( {!! $data['id_bakterisir01'] !!} )
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Hitung Koloni</td>
                                        <td>:</td>
                                        <td>
                                            @if (isset($data['id_bakterihitungkol01']) AND $data['id_bakterihitungkol01'] != 'lainnya')
                                                {!! $data['id_bakterihitungkol01'] !!} 
                                            @endif
                                            @if (isset($data['id_bakterihitungkolteks01']))
                                                {!! $data['id_bakterihitungkolteks01'] !!} 
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Bakteri II</td>
                                        <td>:</td>
                                        <td>
                                            @if (isset($data['id_bakteri02']))
                                                <i>{!! $data['id_bakteri02'] !!}</i>
                                            @endif
                                            @if (isset($data['id_bakterisir02']))
                                                ( {!! $data['id_bakterisir02'] !!} )
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Hitung Koloni</td>
                                        <td>:</td>
                                        <td>
                                            @if (isset($data['id_bakterihitungkol02']) AND $data['id_bakterihitungkol02'] != 'lainnya')
                                                {!! $data['id_bakterihitungkol02'] !!} 
                                            @endif
                                            @if (isset($data['id_bakterihitungkolteks02']))
                                                {!! $data['id_bakterihitungkolteks02'] !!} 
                                            @endif
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    @endif
                </table>
                @if (isset($data['keterangan']))
                    @php
                        if (isset($data['id_kbamc'])){
                            $id_kbamc = $data['id_kbamc'];
                        } else {
                            $id_kbamc = '';
                        }
                        if (isset($data['id_kblef'])){
                            $id_kblef = $data['id_kblef'];
                        } else {
                            $id_kblef = '';
                        }
                        if (isset($data['id_kbfos'])){
                            $id_kbfos = $data['id_kbfos'];
                        } else {
                            $id_kbfos = '';
                        }
                        if (isset($data['id_kbscf'])){
                            $id_kbscf = $data['id_kbscf'];
                        } else {
                            $id_kbscf = '';
                        }
                        if (isset($data['id_sirkbamc'])){
                            $id_sirkbamc = $data['id_sirkbamc'];
                        } else {
                            $id_sirkbamc = '';
                        }
                        if (isset($data['id_sirkblef'])){
                            $id_sirkblef = $data['id_sirkblef'];
                        } else {
                            $id_sirkblef = '';
                        }
                        if (isset($data['id_sirkbfos'])){
                            $id_sirkbfos = $data['id_sirkbfos'];
                        } else {
                            $id_sirkbfos = '';
                        }
                        if (isset($data['id_sirkbscf'])){
                            $id_sirkbscf = $data['id_sirkbscf'];
                        } else {
                            $id_sirkbscf = '';
                        }
                        $keterangan = $data['keterangan'];
                        $cekadatabel = explode('table', $keterangan);
                        if (isset($cekadatabel[1])) {
                            $keterangan = str_replace('</table>', '', $keterangan);
                            $keterangan = str_replace('</tbody>', '', $keterangan);
                            if ($id_kbamc != '' AND $id_sirkbamc != ''){
                                $keterangan .= '<tr><td>&nbsp;</td><td>Amoxicillin - clavulanic acid</td><td style="text-align:center;">'.$id_kbamc.'</td><td style="text-align:center;">'.$id_sirkbamc.'</td></tr>';
                            }
                            if ($id_kblef != '' AND $id_sirkblef != ''){
                                $keterangan .= '<tr><td>&nbsp;</td><td>Levofloxacin</td><td style="text-align:center;">'.$id_kblef.'</td><td style="text-align:center;">'.$id_sirkblef.'</td></tr>';
                            }
                            if ($id_kbfos != '' AND $id_sirkbfos != ''){
                                $keterangan .= '<tr><td>&nbsp;</td><td>Fosfomycin</td><td style="text-align:center;">'.$id_kbfos.'</td><td style="text-align:center;">'.$id_sirkbfos.'</td></tr>';
                            }
                            if ($id_kbscf != '' AND $id_sirkbscf != ''){
                                $keterangan .= '<tr><td>&nbsp;</td><td>Cefoperazone - Sulbactam</td><td style="text-align:center;">'.$id_kbscf.'</td><td style="text-align:center;">'.$id_sirkbscf.'</td></tr>';
                            }
                            $keterangan .= '</tbody></table>';
                        } else {
                            if ($id_kbamc != '' AND $id_sirkbamc != ''){
                                $keterangan = $keterangan.'<br />Amoxicillin - clavulanic acid : '.$id_kbamc.' ('.$id_sirkbamc.')';
                            }
                            if ($id_kblef != '' AND $id_sirkblef != ''){
                                $keterangan = $keterangan.'<br />Levofloxacin : '.$id_kblef.' ('.$id_sirkblef.')';
                            }
                            if ($id_kbfos != '' AND $id_sirkbfos != ''){
                                $keterangan = $keterangan.'<br />Fosfomycin : '.$id_kbfos.' ('.$id_sirkbfos.')';
                            }
                            if ($id_kbscf != '' AND $id_sirkbscf != ''){
                                $keterangan = $keterangan.'<br />Cefoperazone - Sulbactam : '.$id_kbscf.' ('.$id_sirkbscf.')';
                            }
                        }
                        echo 'Komentar:<br />'.$keterangan;
                    @endphp
                @endif
            </td>
        </tr>
        <tr><td colspan="8">&nbsp;</td></tr>
        <tr><td colspan="8">&nbsp;</td></tr>
        <tr>
            <td width="45">&nbsp;</td>
            <td valign="top" colspan="4" align="center">&nbsp;<br />Petugas</td>
            <td valign="top" colspan="3" align="center">Malang {!! $tanggal !!}<br />DPJP</td>
        </tr>
        <tr>
            <td width="45">&nbsp;</td>
            <td valign="top" colspan="4" align="center">{!! $tandatangananalis !!}</td>
            <td colspan="3" align="center" valign="top">{!! $tandatangan !!}</td>
        </tr>
        <tr><td colspan="8">&nbsp;</td></tr>
        <tr>
            <td width="45">&nbsp;</td>
            <td valign="top" colspan="4" align="center">{{ $periksa->nmanalis }}</td>
            <td valign="top" colspan="3" align="center">{{ $periksa->nmdokter }}</td>
        </tr>
    </table>
</body>
</html>
