/**
  * Update the specified prescription in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $prescription = Prescription::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Prescription::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['patient_id'] = $prescription->patient_id;
     foreach (Input::get('medicines') as $id) {
         if (!in_array($id, explode(',', $prescription->medicines))) {
             $medicine = Medicine::find($id);
             $medicine->quantity -= 1;
             $medicine->update();
         }
     }
     foreach (explode(',', $prescription->medicines) as $old_id) {
         if (!in_array($old_id, Input::get('medicines'))) {
             $medicine = Medicine::find($old_id);
             $medicine->quantity += 1;
             $medicine->update();
         }
     }
     $data['medicines'] = implode(",", Input::get('medicines'));
     $prescription->update($data);
     return Redirect::to('prescriptions?id=' . $prescription->patient_id);
 }
 public function print_pres()
 {
     $id = Input::get('id');
     $prescription = Prescription::findOrFail($id);
     $date = date('j F, Y', strtotime($prescription->appointment->date));
     $time = date('H:i:s', strtotime($prescription->appointment->time));
     $doctor_name = $prescription->appointment->employee->name;
     $patient = $prescription->appointment->patient;
     $medicines = [];
     foreach (explode(',', $prescription->medicines) as $id) {
         array_push($medicines, Medicine::find($id));
     }
     $html = "<html><body>" . " <img src='./images/logo_new1.jpg'/>\n                <center>\n                    <h1><u> Prescription </u></h1>\n                </center>\n                <table style='border-collapse: collapse; margin-left:auto; margin-right:auto' cellpadding='7' border='1'>\n\n                    <tr>\n                        <td height='20'><label>Patient Name:</label></td>\n                        <td><label> {$patient->name} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Patient ID:</label></td>\n                        <td><label> {$patient->patient_id} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Visit Date:</label></td>\n                        <td><label> {$date} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Visit Time:</label></td>\n                        <td><label> {$time} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Doctor Name:</label></td>\n                        <td><label> {$doctor_name} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Prescription Code:</label></td>\n                        <td><label> {$prescription->code} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'> <label>Medicines:</label></td>\n                        <td><label>";
     foreach ($medicines as $index => $medicine) {
         $html .= $index + 1 . ' - ' . $medicine->name . "<br />";
     }
     $html .= "</label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Note:</label></td>\n                        <td><label> {$prescription->note} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Dignostic Procedure:</label></td>\n                        <td><label> {$prescription->procedure} </label></td>\n                    </tr>\n                </table>" . "</body></html>";
     return PDF::load($html, 'A4', 'portrait')->show($patient->name . ' Prescription');
 }
Exemple #3
0
 Route::resource('checkupfees', 'CheckupfeesController');
 Route::resource('testfees', 'TestfeesController');
 // PDF Reports
 Route::any('print_pres', ['uses' => 'HomeController@print_pres']);
 // Prescription PDF
 Route::any('print_test', ['uses' => 'HomeController@print_test']);
 // Test Report PDF
 // Prints
 Route::get('app_pres_print', function () {
     $appointments = Appointment::has('prescription')->get();
     $flag = "pres_print";
     return View::make('appointment_based_data.appointments', compact('appointments', 'flag'));
 });
 Route::get('pres_print', function () {
     $id = Input::get('id');
     $prescription = Prescription::findOrFail($id);
     $date = date('j F, Y', strtotime($prescription->appointment->date));
     $time = date('H:i:s', strtotime($prescription->appointment->time));
     $doctor_name = $prescription->appointment->employee->name;
     $patient = $prescription->appointment->patient;
     $medicines = [];
     foreach (explode(',', $prescription->medicines) as $id) {
         array_push($medicines, Medicine::find($id));
     }
     return View::make('printables.prescription_print', compact('prescription', 'date', 'time', 'doctor_name', 'patient', 'medicines'));
 });
 Route::get('app_test_print', function () {
     $appointments = Appointment::has('labtests')->get();
     $flag = "test_print";
     return View::make('appointment_based_data.appointments', compact('appointments', 'flag'));
 });