 <?=$active?>.as
<div class="row" id="info-content" style="display:block">
    <div class="col-md-12">
        <div class="portlet box green-haze" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-user"></i> Informasi Pasien
                </div>
            </div>

            <div class="portlet-body form">
                <form class="form-horizontal form-bordered form-row-stripped" role="form">
                    <div class="form-body">
                        <div class="form-group">
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nomor Rekam Medis </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; BBMC-<?=$this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nrm')?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nama Pasien </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nama_pasien'))?>  / <?=$this->Content_m->get_tipe_pasien($id_re_pasien)?>
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Umur  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_tahun'))?> TAHUN <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_bulan'))?> BULAN
                                    </p>
                                </div>
                                <div class="row">
                                     <div style="padding:0px; <?=$get_kunjungan->id_dokter_jaga!='-1'?'display: block':'display: none'?>">
                                          <label class="form-control-static col-md-4">Dokter </label>
                                          <p class="form-control-static col-md-8">
                                              : &nbsp; 
                                              <?php 
                                              $id_dokter_jaga = $this->Content_m->get_value('bbmc_tr_kunjungan','id_re_kunjungan',$id_re_kunjungan,'id_dokter_jaga');
                                              echo "<b>".$this->Content_m->get_value('bbmc_re_staff_medis','id_staff_medis',$id_dokter_jaga,'staff_medis')."</b>";
                                              ?>  
                                          </p>
                                      </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pendidikan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pendidikan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pendidikan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_jenjang_pendidikan','id_jenj_didik',$id_pendidikan,'nm_jenj_didik');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pekerjaan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pekerjaan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pekerjaan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_pekerjaan','id_pekerjaan',$id_pekerjaan,'nm_pekerjaan');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Alamat  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'alamat'))?> 
                                    </p>
                                </div>
                            </div>
                        </div>                                    
                    </div>
                </form>
                
            </div>
            
        </div>
    </div>
</div>



<?php if($get_kunjungan->id_dokter_jaga == '0'){ ?>
<div class="alert alert-danger">
Silahkan isi pemeriksaan utama terlebih dahulu.
</div>
<?php }else{ ?>
<div class="row" id="portlet-content">
    <div class="col-md-12">
        <div class="portlet light" style="position:relative">           
            <div class="portlet-body form" id="page-content" style="display:none">
              <form action="<?= site_url('front_office/'.$controller_dir.$controller.'/update_data_icd') ?>" method="post" id="<?=$controller?>" enctype="multipart/form-data" class="horizontal-form">
                <input type="hidden" name="id_re_kunjungan" value="<?=$id_re_kunjungan?>">
                <div class="form-body">
                  <div class="alert alert-danger display-hide" style="display:none;" id="error">
                    <button class="close" data-close="alert"></button>
                    <span id="error-text"></span>
                  </div>
  
                  <?php if($active == 'gigi'){ ?>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="icd">

                        <input type="hidden" name="odontogram" value="yes">
                        <h4 class="form-section" style="margin:0px 0px 5px 0px !important; padding-bottom:10px !important; font-size:13px !important"><i class="fa fa-eyedropper"></i><strong> Odontogram </strong> <hr style="margin:10px 0px 0px 0px !important"></h4>
                        <div class="table-responsive">
                            
                           <?php $this->load->view('front_office/ugd/periksa/odontogram')?>

                        </div>
                      </div> 
                    </div>
                  </div>
                  <?php }?>


                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="icd">



                        <h4 class="form-section" style="margin:0px 0px 5px 0px !important; padding-bottom:10px !important; font-size:13px !important"><i class="fa fa-eyedropper"></i><strong> Data ICD </strong> <hr style="margin:10px 0px 0px 0px !important"></h4>
                        <div class="table-responsive">
                          <?php 
                          $this->db->where('id_re_kunjungan',$id_re_kunjungan);
                          $q = $this->Content_m->select_db('bbmc_tr_icd'); 
                          //echo $this->db->last_query();
                          ?>
                          <table id="<?= $controller ?>_table" class="table table-bordered table-striped table-hover" style="margin-bottom:0px; width:100%; font-size:11px !important">
                              <thead>
                                <tr>
                                  <th class="text-center col-md-1" style="font-size:10px !important">No</th>
                                  <th class="text-left col-md-3" style="font-size:10px !important">ICD</th>
                                  <th class="text-left col-md-6" style="font-size:10px !important">Nama ICD</th>
                                  <?php if($active == 'gigi'){ ?>
                                  <th class="text-left col-md-2" style="font-size:10px !important">Gigi</th>
                                  <?php }?>
                                  <th class="text-center col-md-1" style="font-size:10px !important">Aksi</th>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
                                $i=1;
                                foreach ($q->result() as $key ) { ?>
                                <tr style="" class="icd<?=$i?>">   
                                  <input type="hidden" name="id_re_icd[]" value="<?=$key->id_re_icd?>">
                                  <td align="center"><?=$i?></td>
                                  <td align="left">
                                      <?=$this->Content_m->get_value('bbmc_re_icd','id_icd',$key->id_icd,'icd')?>
                                      <input type="hidden" name="id_icd[]" value="<?=$key->id_icd?>">        
                                  </td>
                                  <td align="left">
                                     <?=$this->Content_m->get_value('bbmc_re_icd','id_icd',$key->id_icd,'diagnosa')?>
                                  </td>

                                  <?php if($active == 'gigi'){ ?>
                                  <td class="col-md-2" align="left">
                                      <?=$key->gigi_icd?>
                                  </td>
                                  <?php }?>
                                  
                                  <td align="center"><a data-toggle="tooltip" data-placement="top" title="Hapus ICD" href="<?=site_url()?>/front_office/ugd_dir/ugd/del_icd/<?=$key->id_re_icd?>/<?=$id_re_kunjungan?>" onclick="return confirm('Apakah anda yakin menghapus entry ini?')" data-id="<?=$i?>"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                                </tr>
                                <?php $i++; $id_lab = $key->id_re_icd; }?>
                                <?php for ($ii=$i; $ii < 10; $ii++) { ?>
                                <tr style="border-top:0px; <?=$ii=='1'?'display: table-row':'display: none'?>" class="icd<?=$ii?>">   
                                  <input type="hidden" name="id_re_icd[]" value="tidakada">
                                  <td colspan="1" align="center" style="text-align: center; vertical-align: middle;"><?=$ii?></td>
                                  <td colspan="1" class="col-md-3" align="left">
                                    <select name="id_icd[]" class="icd_select" style="padding: 0px; width: 100%;">
                                        <option value=""></option>
                                        
                                    </select>
                                  </td>
                                  <td colspan="1" align="center"></td>
                                  <?php if($active == 'gigi'){ ?>
                                  <td colspan="1" class="col-md-2" align="left">
                                    <input type="text" name="gigi_icd[]" value="" class="form-control" placeholder="Ketik ..">
                                  </td>
                                  <?php }else { ?>
                                    <input type="hidden" name="gigi_icd[]" value=" ">
                                  <?php }?>
                                  
                                  <td class="col-md-1" align="center" style="text-align: center; vertical-align: middle;"><a data-toggle="tooltip" data-placement="top" title="Hapus ICD" href="javascript:;" class="del_icd" data-id="<?=$ii?>"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                                </tr>
                                <?php }?>
                              </tbody>
                            </table>
                            <a class="btn btn-xs blue add_icd" href="javascript:;" style="margin-top:10px !important">
                              <i class="fa fa-plus"></i>
                            </a>                           
                        </div>
                      </div> 
                    </div>
                  </div>
                  <script type="text/javascript">

                    var a="<?=$i=='1'?'2':$i?>";
                    $(".add_icd").click(function(){
                        $(".icd"+a).css('display','table-row');
                        a++;
                    });

                    $(".del_icd").click(function(){
                        var b= $(this).attr('data-id');
                        $(".icd"+b).css('display','none');
                        if(confirm("Hapus entry ini?")){
                          return true;
                        }
                    });

                    

                  </script>           
                    


                  

                  <br>

                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="icd">
                        <h4 class="form-section" style="margin:0px 0px 5px 0px !important; padding-bottom:10px !important; font-size:13px !important"><i class="fa fa-eyedropper"></i><strong> Data Tindakan </strong> <hr style="margin:10px 0px 0px 0px !important"></h4>
                        <div class="table-responsive">
                          <?php 
                          $id_type_pasien = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_type_pasien');
                          

                          $this->db->where('id_re_kunjungan',$id_re_kunjungan);
                          $q = $this->Content_m->select_db('bbmc_tr_tindakan'); 
                          ?>
                          <table id="<?= $controller ?>_table" class="table table-bordered table-striped table-hover" style="margin-bottom:0px; width:100%; font-size:11px !important">
                              <thead>
                                <tr>
                                  <th class="text-center col-md-1" style="font-size:10px !important">No</th>
                                  <th class="text-left col-md-7" style="font-size:10px !important">Tindakan</th>
                                  <?php if($active == 'gigi'){ ?>
                                  <th class="text-left col-md-2" style="font-size:10px !important">Keterangan</th>
                                  <th class="text-left col-md-2" style="font-size:10px !important">Gigi</th>
                                  <?php }?>
                                  <th class="text-center col-md-1" style="font-size:10px !important">Aksi</th>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
                                $i=1;
                                foreach ($q->result() as $key ) { ?>
                                <tr style="" class="tindakan<?=$i?>">   
                                  <input type="hidden" name="id_re_tindakan[]" value="<?=$key->id_re_tindakan?>">
                                  <td align="center"><?=$i?></td>
                                  <td align="left">
                                      <?=$this->Content_m->get_value('siak_re_account_chart','id',$key->tindakan,'name')?>
                                      <input type="hidden" class="form-control" name="tindakan[]" value="<?=$key->tindakan?>">
                                  </td>
                                  <input type="hidden" class="form-control" name="keterangan[]" value="<?=$key->keterangan?>">
                                  <input type="hidden" class="form-control" name="gigi[]" value="<?=$key->gigi?>">
                                  <?php if($active == 'gigi'){ ?>
                                  <td colspan="1" class="col-md-2" align="left">
                                      <?=$key->keterangan?>
                                  </td>
                                  <td colspan="1" class="col-md-2" align="left">
                                      <?=$key->gigi?>
                                  </td>
                                  <?php }?>
                                  <td align="center"><a data-toggle="tooltip" data-placement="top" title="Hapus Tindakan" href="<?=site_url()?>/front_office/ugd_dir/ugd/del_tindakan/<?=$key->id_re_tindakan?>/<?=$id_re_kunjungan?>" onclick="return confirm('Apakah anda yakin menghapus entry ini?')" data-id="<?=$i?>"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                                </tr>
                                <?php $i++; $id_tindakan = $key->id_re_tindakan; }?>
                                <?php for ($ii=$i; $ii < 10; $ii++) { ?>
                                <tr style="border-top:0px; <?=$ii=='1'?'display: table-row':'display: none'?>" class="tindakan<?=$ii?>">   
                                  <input type="hidden" name="id_re_tindakan[]" value="tidakada">
                                  <td colspan="1" align="center" style="text-align: center; vertical-align: middle;"><?=$ii?></td>
                                  <td colspan="1" class="col-md-7" align="left">
                                    <select name="tindakan[]" class="form-control sel2">
                                        <option value=""></option>
                                        <?php 

                                        

                                        
                                        if($id_type_pasien == '1' || $id_type_pasien == '2'){
                                          //$this->db->where('id_tindakan >','0');
                                          //$this->db->where('id_tindakan <','10');
                                          if($active == 'subspesialis-1'){
                                            $array_in = array('7');
                                          }else if($active == 'subspesialis-2'){
                                            $array_in = array('8');
                                          }else if($active == 'spesialis'){
                                            $array_in = array('7','8','9');
                                          }else if($active == 'gigi'){
                                            $array_in = array('6');
                                          }else{
                                            $array_in = array('1','3');
                                          }
                                          $this->db->order_by('name');
                                          $this->db->where_in('id_tindakan',$array_in);


                                        }else if($id_type_pasien == '3'){
                                          $this->db->where('id_tindakan','11');
                                        }else if($id_type_pasien == '4'){
                                          $this->db->where('id_tindakan','12');
                                        }else if($id_type_pasien == '5'){
                                          $this->db->where('id_tindakan','13');
                                        }
                                        $a = $this->Content_m->select_db('siak_re_account_chart');
                                        foreach ($a->result() as $key ) { 
                                          $id= $key->id;
                                        ?>
                                         <option value="<?=$id?>"><?=ucwords(strtolower($key->name))?></option>
                                        <?php }?>
                                    </select>     
                                  </td>
                                  <?php if($active == 'gigi'){ ?>
                                  <td colspan="1" class="col-md-2" align="left">

                                    <input type="text" name="keterangan[]" value="" class="form-control" placeholder="Ketik ..">
                                  </td>
                                  <td colspan="1" class="col-md-2" align="left">
                                    <input type="text" name="gigi[]" value="" class="form-control" placeholder="Ketik ..">
                                  </td>
                                  <?php }else{ ?>
                                     <input type="hidden" name="gigi[]" value="">
                                     <input type="hidden" name="keterangan[]" value="">
                                  <?php }?>
                                  <td class="col-md-1" align="center" style="text-align: center; vertical-align: middle;"><a data-toggle="tooltip" data-placement="top" title="Hapus Tindakan" href="javascript:;" class="del_tindakan" data-id="<?=$ii?>"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                                </tr>
                                <?php }?>
                              </tbody>
                            </table>
                            <a class="btn btn-xs blue add_tindakan" href="javascript:;" style="margin-top:10px !important">
                              <i class="fa fa-plus"></i>
                            </a>                           
                        </div>
                      </div> 
                    </div>
                  </div>
                  <script type="text/javascript">

                    var a2="<?=$i=='1'?'2':$i?>";
                    $(".add_tindakan").click(function(){
                        $(".tindakan"+a2).css('display','table-row');
                        a2++;
                    });

                    $(".del_tindakan").click(function(){
                        var b2= $(this).attr('data-id');
                        $(".tindakan"+b2).css('display','none');
                        if(confirm("Hapus entry ini?")){
                          return true;
                        }
                    });

                  </script>       


                </div>
                <div class="form-actions right">
                  <a type="button" class="btn default" href="<?= site_url('front_office/'.$controller_dir.$controller) ?>">Kembali</a>
                  <button type="submit" class="btn blue"><i class="fa fa-check"></i> Simpan</button>
                </div>
              </form>
            </div>
            <?php $this->load->view('front_office/include/loading');?>
        </div>
    </div>
</div>
<?php }?>


<script type="text/javascript">
  $(document).ready(function() {
     /*-------------Datepicker-------------*/
    $(".sel2").select2({
      placeholder: "Pilih .. ",
      language: "id"
    });

    $(".icd_select").select2({
        placeholder: "Pilih .. ",
        language: "id",
        ajax: {
          url: "<?=site_url('front_office/ajax/select2_icd')?>",
          dataType: 'json',
          delay:250,
          type:"POST",
          data: function(params) {
              return {
                untuk: 'all_data',
                  term: params.term || '',
                  page: params.page || 1
              }
          }
        },
        escapeMarkup: function (markup) {return markup;},
        minimumInputLength: 1,
        templateResult: function(repo){
          if(repo.loading)
              return repo.text;
          return repo.value;
        },
        templateSelection: function(repo){return repo.value || repo.text;}
      });


    $("#loading-content,#loading").fadeOut("fast", function() {
      $("#page-content").fadeIn("fast");
    });

  });
</script>

<?php $this->load->view('front_office/script/form_data'); ?>
