<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$lahir = new DateTime($result['tglLahir']);
$kunjungan = new DateTime($result['tglKunjungan']);
$umur = $lahir->diff($kunjungan)->y;

$masa_berlaku = strtotime('+90 day', strtotime($kunjungan->format('Y-m-d')));
?>
<table class="center" width="920px" style="margin-bottom: 10px;">
  <tr>
    <td width="600px"><img src="./_asset/img/logo_bpjs.png" width="250px"></td>
    <td>
      <?php echo $result['ppk']['kc']['kdKR']['nmKR'] ?><br>
      Kantor Cabang <?php echo $result['ppk']['kc']['nmKC'] ?>
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center" style="font-size:20px; font-weight: bold;">Surat Rujukan FKTP</td>
  </tr>
</table>
<table class="center" width="920px" style="border: 1px solid #000000;">
  <tr>
    <td>
      <table width="900px" style="border: 1px solid #000000; margin: 10px;">
        <tr>
          <td width="140px">No. Rujukan</td>
          <td>: <?php echo $result['noRujukan'] ?></td>
          <td rowspan="3" align="right">
            <img src="./barcode/generate/?codetype=code39&size=60&text=<?php echo $result['noRujukan'] ?>" width="350px" height="40px">
          </td>
        </tr>
        <tr>
          <td width="140px">FKTP</td>
          <td>: <?php echo $result['ppk']['nmPPK'] ?> (<?php echo $result['ppk']['kdPPK'] ?>)</td>
        </tr>
        <tr>
          <td width="140px">Kabupaten / Kota</td>
          <td>: <?php echo $result['ppk']['kc']['dati']['nmDati'] ?> (<?php echo $result['ppk']['kc']['dati']['kdDati'] ?>)</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="900px" style="border: 0px solid #000000; margin: 10px;">
        <tr>
          <td width="160px">Kepada Yth. TS Dokter</td>
          <td>: <?php echo $result['poli']['nmPoli'] ?></td>
        </tr>
        <tr>
          <td width="160px">Di</td>
          <td>: <?php echo $result['ppkRujuk']['nmPPK'] ?></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="900px" style="border: 0px solid #000000; margin: 10px;">
        <tr>
          <td colspan="6">Mohon pemeriksaan dan penangan lebih lanjut pasien :</td>
        </tr>
        <tr>
          <td width="160px">Nama</td>
          <td width="350px">: <?php echo $result['nmPst'] ?></td>
          <td>Umur :</td>
          <td><?php echo $umur ?> Tahun</td>
          <td>:</td>
          <td><?php echo $result['tglLahir'] ?></td>
        </tr>
        <tr>
          <td width="160px">Nomor Kartu BPJS</td>
          <td>: <?php echo $result['nokaPst'] ?></td>
          <td>Status: </td>
          <td><b>[ <?php echo $result['pisa'] ?> ] </b> Utama/Tanggungan</td>
          <td></td>
          <td><b>[ <?php echo $result['sex'] ?> ]</b> (L/P)</td>
        </tr>
        <tr>
          <td width="160px">Diagnosa</td>
          <td colspan="5">: <?php echo $result['diag1']['kdDiag']." (".$result['diag1']['nmDiag'].")"; if($result['diag2'] != null){ echo '<br>'.$result['diag2']['kdDiag']." (".$result['diag2']['nmDiag'].")";}  if($result['diag3'] != null){ echo '<br>'.$result['diag3']['kdDiag']." (".$result['diag3']['nmDiag'].")"; } ?> </td>
        </tr>
        <tr>
          <td width="160px">Catatan</td>
          <td colspan="5">: <?php echo $result['catatan'] ?></td>
        </tr>
        <tr>
          <td width="160px" valign="top">Telah diberikan</td>
          <td colspan="5" height="70px" valign="top">: </td>
        </tr>
        <tr>
          <td colspan="6">Atas bantuannya, diucapkan terima kasih</td>
        </tr>
        <tr>
          <td colspan="3"></td>
          <td colspan="3" align="center">Salam Sejawat<br><?php echo date('d M Y') ?></td>
        </tr>
        <tr>
          <td colspan="6" style="font-size: 11px;"><br><br><br></td>
        </tr>
        <tr>
          <td colspan="6" style="font-size: 11px;">Tgl. Rencana Berkunjung : <?php echo $result['tglEstRujuk'] ?></td>
        </tr>
        <tr>
          <td colspan="3" style="font-size: 11px;">Surat rujukan berlaku 1[satu] kali kunjungan sampai dengan: <?php echo date('d-m-Y', $masa_berlaku); ?></td>
          <td colspan="3" align="center"><?php echo $result['dokter']['nmDokter'] ?></td>
        </tr>
      </table>
    </td>
  </tr>
</table>