Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. function tambah_rm($id)
  2. {
  3. $this->load->helper('form');
  4. $this->load->library('form_validation');
  5.  
  6. $data['title'] = 'Tambah Detail Rekam Medis';
  7.  
  8. $this->form_validation->set_rules('tgl_berobat', 'tgl_berobat', 'required');
  9. $this->form_validation->set_rules('anamnesa', 'anamnesa', 'required');
  10. $this->form_validation->set_rules('diagnosa', 'diagnosa', 'required');
  11. $this->form_validation->set_rules('therapi', 'therapi', 'required');
  12. $this->form_validation->set_rules('keterangan', 'keterangan', 'required');
  13.  
  14. if ($this->form_validation->run() === FALSE)
  15. {
  16. $data['obat']=$this->m_pasien->get_obat();
  17. $data['header']=$this->m_pasien->header_pasien($id)->row_array();
  18. $this->template->load('template','v_tambahRM',$data);
  19.  
  20. }
  21. else
  22. {
  23. $this->m_pasien->tambahrm($data);
  24. redirect('pasien');
  25. }
  26. }
  27.  
  28. function tambahrm()
  29. {
  30. $this->load->helper('url');
  31. $username = trim($this->session->userdata('id_user'));
  32. $data = array(
  33. 'tgl_berobat' => $this->input->post('tgl_berobat'),
  34. 'anamnesa' => $this->input->post('anamnesa'),
  35. 'diagnosa' => $this->input->post('diagnosa'),
  36. 'therapi' => $this->input->post('therapi'),
  37. 'keterangan' => $this->input->post('keterangan'),
  38. 'id_user' => $username,
  39. 'id_pasien' => $this->input->post('id_pasien'),
  40. );
  41.  
  42. if ($id == 0) {
  43. return $this->db->insert('tbl_riwayat', $data);
  44. } else {
  45. $this->db->where('id', $id);
  46. return $this->db->update('tbl_riwayat', $data);
  47. }
  48. }
  49.  
  50. function get_obat()
  51. {
  52. $data_obat = array();
  53. $this->db->select('nama_obat');
  54. $this->db->from('tbl_obat');
  55. $query = $this->db->get();
  56.  
  57. if ($query->num_rows() > 0) {
  58. foreach ($query->result_array() as $row) {
  59. $data_obat[] = $row;
  60. }
  61. }
  62. return $data_obat;
  63. }
  64.  
  65. <div class="form-group m-b-20">
  66. <div class="col-xs-12">
  67. <label for="therapi">Therapi</label>
  68. <select class=" form-control js-example-basic-multiple" multiple="multiple" name="diagnosa">
  69. <?php
  70. foreach($obat as $option)
  71. {
  72. ?>
  73. <option value="<?=$option['nama_obat']?>"><?=$option['nama_obat']?></option>
  74. <?php
  75. }
  76. ?>
  77. </select>
  78. </div>
  79. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement