Advertisement
cdsatrian

rm

Jul 5th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.20 KB | None | 0 0
  1. <?php
  2. $aksi="menu/menu_rm/aksi_rm.php";
  3. switch($_GET[act]){
  4.   // Tampil rekam_medis
  5.   default:
  6.     echo "<h2>Data Rekam Medis</h2>
  7.        <input type=button value='Tambah Data'
  8.        onclick=\"window.location.href='?menu=rekam_medis&act=tambahrm';\">
  9.        <table>
  10.        <tr><th>No</th><th>ID RM</th><th>Kode RM</th><th>ID Pasien</th><th>Diagnosa</th><th>ID Obat</th><th>Hasil Lab</th><th>aksi</th></tr>";
  11.     $tampil=mysql_query("SELECT * FROM rekam_medis ORDER BY id_rm ASC");
  12.     $no=1;
  13.     while ($r=mysql_fetch_array($tampil)){
  14.        echo "<tr><td>$no</td>
  15.           <td>$r[id_rm]</td>
  16.                        <td>$r[id_pasien]</td>
  17.                        <td>$r[id_dokter]</td>
  18.                        <td>$r[diagnosa]</td>            
  19.                        <td>$r[id_obat]</td>                    
  20.                        <td>$r[hasil_lab]</td>                                          
  21.           <td><a href=?menu=rekam_medis&act=editrm&id=$r[id_rm]>Edit</a> |
  22.                      <a href=$aksi?menu=rekam_medis&act=hapus&id=$r[id_rm]>Hapus</a>
  23.           </td></tr>";
  24.       $no++;
  25.     }
  26.     echo "</table>";
  27.     break;
  28.  
  29.    // Form tambah rekam_medis
  30.   case "tambahrm":
  31.  
  32.     $sql="SELECT id_dokter,nm_dokter "
  33.         ."FROM dokter";
  34.     $result=mysql_query($sql);
  35.     $dokter=array();
  36.     while($row=mysql_fetch_object($result))
  37.     {
  38.       $dokter[]=$row;
  39.     }
  40.     mysql_free_result($result);
  41.     $sql="SELECT id_pasien,nm_pasien "
  42.         ."FROM pasien";
  43.     $result=mysql_query($sql);
  44.     $pasien=array();
  45.     while($row=mysql_fetch_object($result))
  46.     {
  47.       $pasien[]=$row;
  48.     }
  49.     mysql_free_result($result);
  50.     $sql="SELECT id_obat,nm_obat "
  51.         ."FROM obat";
  52.     $result=mysql_query($sql);
  53.     $obat=array();
  54.     while($row=mysql_fetch_object($result))
  55.     {
  56.       $obat[]=$row;
  57.     }
  58.     mysql_free_result($result);
  59.    
  60.         ."<form method='POST'>\n"
  61.         ."<input type='hidden' name='act' value='save' />"
  62.         ."<table>\n"
  63.         ."<tr><td>Kode RM</td><td colspan='2'><input type='text' id='kd_rm' name='kd_rm' /></td></tr>\n"
  64.         ."<tr><td>Nama Dokter</td><td colspan='2'><select id='id_dokter' name='id_dokter'>";
  65.     foreach($dokter as $dok)
  66.     {
  67.       echo "<option value='".$dok->id_dokter."'>".$dok->nm_dokter."</option>";
  68.     }
  69.     echo "</select></td></tr>\n"
  70.         ."<tr><td>Nama Pasien</td><td colspan='2'><select id='id_pasien' name='id_pasien'>";
  71.     foreach($pasien as $pas)
  72.     {
  73.       echo "<option value='".$pas->id_pasien."'>".$pas->nm_pasien."</option>";
  74.     }
  75.     echo "</select></td></tr>\n"
  76.         ."<tr valign='top'><td>Obat</td><td id='drugbox'><div class='obat'><select name='id_obat[]'>";
  77.     foreach($obat as $dt)
  78.     {
  79.       echo "<option value='".$dt->id_obat."'>".$dt->nm_obat."</option>";
  80.     }
  81.     echo "</select></div></td><td><span class='btn_obat' id='add_obat'>add</span><span class='btn_obat' id='del_obat'>del</span></td></tr>\n"
  82.         ."<tr><td>Diagnosa</td><td colspan='2'><input type='text' id='diagnosa' name='diagnosa' /></td></tr>\n"
  83.         ."<tr><td>Hasil lab</td><td colspan='2'><input type='text' id='hasil_lab' name='hasil_lab' /></td></tr>\n"
  84.         ."<tr><td colspan='3' align='center'><input type='submit' name='submit' value='simpan' class='btn'/></td></tr>\n"
  85.         ."</table>\n"
  86.         ."</form>\n";
  87. ?>
  88. <script>
  89.   $(document).ready(function(){
  90.     $('#add_obat').click(function(){
  91.       $('.obat').first().clone().appendTo('#drugbox');
  92.     });
  93.     $('#del_obat').click(function(){
  94.       $('.obat').last().remove();
  95.     });    
  96.   });
  97. </script>
  98. <?php    
  99.      break;
  100.   // Form Edit rekam_medis
  101.   case "editrm":
  102.     $edit=mysql_query("SELECT * FROM rekam_medis WHERE id_rm='$_GET[id]'");
  103.     $r=mysql_fetch_array($edit);
  104.  
  105.     echo "<h2>Edit rekam_medis</h2>
  106.        <form method=POST action=$aksi?menu=rekam_medis&act=update>
  107.        <input type=hidden name=id value='$r[id_rm]'>
  108.        <table>
  109.        <tr><td>ID Rekam Medis</td><td> : <input type=text name='id_rm' value='$r[id_rm]'></td></tr>
  110.                 <tr><td>ID Pasien</td><td> : <select name='id_pasien'> ";
  111.                   $hasil=mysql_query('SELECT * from pasien');
  112.                   while($cetak=mysql_fetch_array($hasil)){
  113.                   echo"<option value='".$cetak ['id_pasien']."'>
  114.                 ".$cetak['id_pasien']."-".$cetak['nm_pasien']."</option>";}
  115.                   echo"</select>
  116.         <tr><td>Diagnosa</td><td> : <input type=text name='diagnosa'value='$r[diagnosa]'></td></tr>            
  117.        <tr><td>Obat</td><td> : <select name='id_obat'> ";
  118.                   $hasil=mysql_query('SELECT * from obat');
  119.                   while($cetak=mysql_fetch_array($hasil)){
  120.                   echo"<option value='".$cetak ['id_obat']."'>
  121.                 ".$cetak['id_obat']."-".$cetak['nama_obat']."</option>";}
  122.                   echo"</select>        
  123.                 <tr><td>Hasil Lab</td><td> : <input type=text name='telp'value='$r[hasil_lab]'></td></tr>                              
  124.        <tr><td colspan=2><input type=submit value=Update>
  125.                          <input type=button value=Batal onclick=self.history.back()></td></tr>
  126.        </table></form>";
  127.     break;  
  128. }
  129. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement