Ejemplo n.º 1
0
 public function update(Request $request, $id, $id_dokter, $kode_visit)
 {
     if (Input::get('ok')) {
         RMTemp::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->delete();
         $updateRM = ['status_validasi' => 1];
         $rekamMedik = RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRM);
         return redirect('dashboard');
     }
     //fetch the data from the form first
     $rekamMedik = RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->get()->first();
     $kode_visit = $request->input('kode_visit');
     $this->validate($request, ['id' => 'required', 'id_dokter' => 'required', 'usia_berobat' => 'required', 'tgl_visit' => 'required', 'diagnosis' => 'required', 'tindakan' => 'required']);
     $format_tgl_info_old = Input::get('tgl_visit');
     //then check the type of user trying to update the data
     if (Auth::user()->is('admin')) {
         $updateRM = ['status_validasi' => 0];
         $kode_visit = $request->kode_visit;
         $id_dokter = $request->id_dokter;
         RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRM);
         //fetch email from admin
         $email = Auth::user()->email;
         $id_admin = Admin::where('email', $email)->value('id');
         $temp = RMTemp::create(['id' => $request->input('id'), 'kode_visit' => $request->input('kode_visit'), 'id_dokter' => $request->input('id_dokter'), 'usia_berobat' => $request->input('usia_berobat'), 'tgl_visit' => date("Y-m-d", strtotime($format_tgl_info_old)), 'tinggi_badan' => $request->input('tinggi_badan'), 'berat_badan' => $request->input('berat_badan'), 'tekanan_darah' => $request->input('tekanan_darah'), 'resep' => $request->input('resep'), 'anamnesis' => $request->input('anamnesis'), 'diagnosis' => $request->input('diagnosis'), 'tindakan' => $request->input('tindakan'), 'id_admin' => $id_admin]);
         Session::flash('message', 'Permintaan pengubahan record rekam medik akan diproses! Silahkan menunggu konfirmasi dari dokter yang bersangkutan!');
         return redirect('rekam-medik');
     } else {
         if (Auth::user()->is('super.user')) {
             $format_tgl_info_old = Input::get('tgl_visit');
             $updateRM = ['usia_berobat' => $request->input('usia_berobat'), 'tgl_visit' => date("Y-m-d", strtotime($format_tgl_info_old)), 'tinggi_badan' => $request->input('tinggi_badan'), 'berat_badan' => $request->input('berat_badan'), 'tekanan_darah' => $request->input('tekanan_darah'), 'resep' => $request->input('resep'), 'anamnesis' => $request->input('anamnesis'), 'diagnosis' => $request->input('diagnosis'), 'tindakan' => $request->input('tindakan')];
             RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRM);
             Session::flash('message', 'Rekam Medik ' . $id . '-' . $id_dokter . '-' . $kode_visit . ' berhasil dimutakhirkan!');
             // return redirect(action('RekamMedikController@edit', $rekamMedik->id, $rekamMedik->kode_visit));
             return redirect('rekam-medik');
         }
     }
     return view('rekam-medik');
 }
Ejemplo n.º 2
0
 public function validateTemp($id, $id_dokter, $kode_visit)
 {
     if (Input::get('terima')) {
         $temp = RMTemp::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->first();
         $updateRM = ['usia_berobat' => $temp->usia_berobat, 'tgl_visit' => $temp->tgl_visit, 'tinggi_badan' => $temp->tinggi_badan, 'berat_badan' => $temp->berat_badan, 'tekanan_darah' => $temp->tekanan_darah, 'resep' => $temp->resep, 'anamnesis' => $temp->anamnesis, 'diagnosis' => $temp->diagnosis, 'tindakan' => $temp->tindakan, 'status_validasi' => 1];
         //update RekamMedik
         RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRM);
         //delete the data on temp
         RMTemp::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->delete();
         Session::flash('message', 'Rekam Medik ' . $id . '-' . $id_dokter . '-' . $kode_visit . ' berhasil dimutakhirkan!');
         return redirect('dashboard');
     } else {
         $updateRMTemp = ['status_cek' => 1];
         // $updateRM = (['status_validasi' => 1]);
         // RekamMedik::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRM);
         RMTemp::where('id', $id)->where('id_dokter', $id_dokter)->where('kode_visit', $kode_visit)->update($updateRMTemp);
         return redirect('dashboard');
     }
 }